develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000317.003] missing slice of reference

M.J.T. Guy
March 17, 2000 09:06
Re: [ID 20000317.003] missing slice of reference
Message ID: (Johan Vromans) wrote
> "M.J.T. Guy" <> writes:
> > >                                                        And I cannot
> > > see why 'scalar(@x)->[2]' produces the 3rd element of array @x.
> > 
> > Where does it say anything about scalar context?
> As far as I can tell, scalar(@x) is 4, and 4->[2] points to nothing
> defined, most certainly not to $x[2].

Oops.   I interpreted your remark as if
"@x->[2] is the same as scalar(@a)->[2] so it should behave ..."
and I meant "Where does it say the LHS of -> is scalar context?.
I didn't realise you meant a literal scalar($a).

#perl -Mstrict -wle 'my @a=(7,6,5,4);print scalar(@a)->[2]'

Eeeek!    That *must* be a bug.

Mike Guy Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About