Why is assignment to a list of variables inconsistent?

Viewed 288

To save 2 values from a list returned by a sub and throw the third away, one can;

(my $first, my $second) = (1, 2, 3);
print $first, "\n";
print $second, "\n";
exit 0;

and it works as expected (in both perl5 and perl6). If you want just the first however;

(my $first) = (1, 2, 3);
print $first, "\n";
exit 0;

... you get the whole list. This seems counter-intuitive - why the inconsistency?

2 Answers
Related