which to me looks like: $OPER = 's' = 'c'; when $test ne 'c' is true. And that should fail with a "Can't modify constant item in scalar assignment" error.
You're forgetting the precedence -- or should I say associativity? -- no, I think precedence is correct here. It is actually like ($OPER = 's') = 'c', which, while admittedly bizarre, is perfectly legal, since $OPER = 's' evaluates to an lvalue $OPER. Observe the difference:
sidhekin@blackbox:~$ perl -le '($c = 1) = 2; print $c' 2 sidhekin@blackbox:~$ perl -le '$c = 1 = 2; print $c' Can't modify constant item in scalar assignment at -e line 1, near "2; +" Execution of -e aborted due to compilation errors. sidhekin@blackbox:~$
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
In reply to Re^4: ternary operator
by Sidhekin
in thread ternary operator
by pglenski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |