in reply to Re^2: array assignment with list operator , no parenthesis
in thread array assignment with list operator , no parenthesis

Not (quite) accurate. Consider
($foo) = (7,2,4); # list context - comma := list separator print $foo,"\n"; __END__ 7
$foo = (7,2,4); # scalar context despite of parens - comma := 'C' co +mma print $foo,"\n"; __END__ 4
$foo = (7,2,4) x 3; # comma := 'C' comma, 'x' operates on scalar print $foo,"\n"; __END__ 444
@foo = (7,2,4) x 3; # comma := list separator, 'x' operates on list print @foo,"\n"; __END__ 724724724

Parens are just grouping, thus for precedence. They do not provide list context. The list context in

@foo = (7,2,4);

is enforced by the LHS of the expression. But it is perfectly legal to assign a single scalar to an array. The parens are for precedence first, and then, that being clear, the comma is disambiguated as a list separator, as enforced by the LHS.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^4: array assignment with list operator , no parenthesis
by ikegami (Patriarch) on May 15, 2007 at 17:29 UTC

    I was refering to the parsing context (building a block vs building a list), not the return context (list vs scalar).