in reply to Difference between my ($foo) & my $foo
With:
Now:
Then:
But:
my (undef, $a, undef, $b, @rest, $c) = (1, 2, 3, 4, 5, 6, 7, 8);
Now:
- @rest will be greedily assigned: @rest = (5, 6, 7, 8)
- the other variables are respectively assigned: ($a, $b, $c) = (2, 4, undef)
Then:
my $count = @rest; # 4 - because there are four items (scalar contex +t) my ($first) = @rest; # 5 - because first item is 5 (list context)
But:
my $last = (11, 22, 33, 999); # 999 - because assigning LIST to scalar + only picks last item
|
---|
In Section
Seekers of Perl Wisdom