in reply to arrays and lists, hmmm
Hi morgon,
Personally I find the easiest way to think about this is by looking at the Comma Operator:
In scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value. ... In list context, it's just the list argument separator, and inserts both its arguments into the list. These arguments are also evaluated from left to right.
And as Athanasius said, the parens are required because the assignment operator has higher precedence than the comma operator:
$ perl -MO=Deparse,-p -e ' $x= "a","b" ' (($x = 'a'), '???'); $ perl -MO=Deparse,-p -e ' $x=("a","b") ' ($x = ('???', 'b'));
Hope this helps,
-- Hauke D
|
|---|