in reply to Re^2: List assignment in scalar context
in thread List assignment in scalar context
Oh come off it.
sub list { return 1..5 } my ($a,$b,$c); my $n1 = ($a,$b,$c) = list(); my $n2 = my @x = ($a,$b,$c) = list(); print "$n1 ... $n2\n"; ---- 5 ... 3
When you have scalar = list = list, you will always get the count of items in the rightmost list in scalar. In your $n2 example, your array is getting three items from the list. It isn't a scalar, so it isn't getting the count. What else would be expected? The behavior that merlyn is referring to is the reason why you don't see the complete count in the scalar.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: List assignment in scalar context
by dragonchild (Archbishop) on Jan 10, 2005 at 19:25 UTC | |
by !1 (Hermit) on Jan 10, 2005 at 19:32 UTC | |
by jonadab (Parson) on Jan 11, 2005 at 00:15 UTC |
In Section
Seekers of Perl Wisdom