stevieb++ and johngg++ have explained the problem and its solution, but note also that this feature (yes, feature) is called "list flattening". Any lvalue array (or hash) in a list assignment will consume all remaining items in the assigned (RHS) list.
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -e
"my ($w, $x, @y, @z);
($w, $x, @y, @z) = qw(Dubya Eks Why? Zee-List-Is-Flattened);
dd 'w', $w;
dd 'x', $x;
dd 'y', \@y;
dd 'z', \@z;
"
("w", "Dubya")
("x", "Eks")
("y", ["Why?", "Zee-List-Is-Flattened"])
("z", [])
Try this with %y (a hash) in place of the @y array, and with any combination of scalar(s), array(s) or hash(s) in place of the @z array.
BTW, in the category of Stupid Hash Tricks, try this:
c:\@Work\Perl\monks>perl -wMstrict -le
"my %hash = (4 => 12, 34 => 102);
;;
while (my %h = each %hash) {
printf qq{%s => %s \n}, %h;
}
"
4 => 12
34 => 102
Update: A solution using assignment to an array (update: could also be a hash %kv) (also not recommended) might be something like:
c:\@Work\Perl\monks>perl -wMstrict -le
"my %hash = (4 => 12, 34 => 102);
;;
while (my @kv = each %hash) {
local $, = ' => ';
print @kv;
}
"
4 => 12
34 => 102
(Update: In adding this Update, I screwed up the previous BTW example code. Everything's fixed now.)
Give a man a fish: <%-{-{-{-<
|