perl -MO=Deparse -e 'sub Foo() {}; (time ? @a=() : $a) = Foo();'
and if you try the more natural:sub Foo () { } time ? @a = () : $a = Foo;
perl -MO=Deparse -e 'sub Foo() {}; (time ? @a : $a) = Foo();'
Perl needs to examine the left-hand side in order to know the context in which to run Foo(), but it delays execution until Foo() has been run. Therefore it can't decide on the context and fails.Assignment to both a list and a scalar at -e line 1, near ");"
In reply to Re: ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
by Loops
in thread ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
by ed_hoch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |