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

Re: [ID 20000317.003] missing slice of reference

From:
M.J.T. Guy
Date:
March 17, 2000 09:06
Subject:
Re: [ID 20000317.003] missing slice of reference
Message ID:
E12W0Cu-0001lc-00@ursa.cus.cam.ac.uk
JVromans@squirrel.nl (Johan Vromans) wrote
> "M.J.T. Guy" <mjtg@cus.cam.ac.uk> 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]'
5
#

Eeeek!    That *must* be a bug.


Mike Guy



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About