Aaron Sherman writes: > I would expect [] to force itself into scalar context anyway. Is there > ever a reason to want otherwise? Clearly the entire point of [] is to > create a scalar array ref from a list of arguments. > > More to the point is there ever a reason to want any array ref in list > context to NOT explode other than []? I can't think of any. > > push @a, $b > > Is it too non-obvious that if $b is an array ref, then this is going to > extend @a by $b.length elements?
Quite a bit too subtle, yes. While array references are now doing many of the same things in similar contexts as arrays, flattening in list context is not one of them. Array references are still different beasts from arrays. Your push example is one of the reasons why. Some time back, Larry said that you had to do: push @a, @$b; Just like in Perl 5. But this was before * was a unary operator instead of a context forcing operator. That is, as of A6: sub foo(@a, @b, @c, @d, @e); foo(@a, @b, [EMAIL PROTECTED], @d); # Flatten @c and @d into the parameter list But now, it's: foo(@a, @b, [EMAIL PROTECTED], @d); # Flatten @c into the parameter list So that might mean that push looks like: push @a, *$b; Luke