in reply to Re: Array/List Strangeness
in thread Array/List Strangeness
Noone answered the question, and I'm also interested in knowing too. I don't know why they don't all behave one way or the other.
the "why" is explained in the docs, it's meant to produce a false value in a while loop.
from perldata#Slices
This makes it easy to write loops that terminate when a null list is returned: 1. while ( ($home, $user) = (getpwent)[7,0]) { 2. printf "%-8s %s\n", $user, $home; 3. }
If there's a reason to do it for list slices, the same reason exists for array slices.
The OP didn't use any array slices (jethro did). But I have to say I'm not happy with this non-orthogonality...
UPDATE: IMHO there should be a special perldoc only for lists explaining the differences to arrays and how to avoid confusion...
Cheers Rolf
|
|---|