in reply to ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
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 ");"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
by Athanasius (Archbishop) on Aug 04, 2013 at 08:05 UTC | |
by choroba (Cardinal) on Aug 05, 2013 at 09:36 UTC | |
by Anonymous Monk on Aug 05, 2013 at 10:42 UTC | |
by ed_hoch (Sexton) on Aug 05, 2013 at 17:54 UTC |