develooper Front page | perl.perl5.porters | Postings from August 2012

[perl #114498] List slice *sometimes* ignores undefined items

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
August 20, 2012 18:53
Subject:
[perl #114498] List slice *sometimes* ignores undefined items
Message ID:
rt-3.6.HEAD-11172-1345513998-901.114498-15-0@perl.org
On Sun Aug 19 08:27:12 2012, jrw32982@yahoo.com wrote:
> @x = ( (2)[0,1,2] );
> @y = ( (2)[� 1,2] );
> use Data::Dumper;
> print Dumper \@x, \@y;
> 
> produces:
> 
> $VAR1 = [
> ��������� 2,
> ��������� undef,
> ��������� undef
> ������� ];
> $VAR2 = [];
> 
> This seems inconsistent.� The first result (for @x) was expected. The
> second (for @y) wasn't.
> 

I don't think it's particularly inconsistent.  In the first case the
slicing operation finds a defined element in the 0-index position of the
RH and assigns it to the array on the LH, and then (I suppose) proceeds
to auto-vivify.  In the second case, the slicing operation finds no
element in the 0-index position, has nothing to assign, and stops there.

If anything, I think the second case is more intuitively plausible than
the first.

I couldn't find anything in Camel book 3rd or 4th edition that clarifies
this definitively.

Thank you very much.
Jim Keenan


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114498

Thread Previous | Thread Next


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