Compare
(time ? ($count=()) : $a) = Foo(); ## list+scalar (time ? @a : $a) = Foo(); ## list+scalar (time ? (@a=()) : $a) = Foo(); ## list+scalar (time ? $a=() : $a) = Foo(); ## scalar is scalar (time ? @a=() : $a) = Foo(); ## skates through as scalar $a[0]
It appears perl doesn't recognize the array+assignment(accumulator) as a list without an extra parenthesis, so it does what it thinks should happen
Is this a bug? Yes, in that it already protects programmers from this misunderstanding ( perldiag#Assignment to both a list and a scalar), but it missed this particular variant
Also, Deparse isn't bulletproof :) Deparse says \my(%hash) is the same as \my %hash but it isn't
In reply to Re^4: ternary operator as lvalue failing to induce evaluation of right-hand expression in list context (accumulator)
by Anonymous Monk
in thread ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
by ed_hoch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |