There may be a Perl bug here. Because of operator precedence I'd have expected that the trinary experession shouldn't compile. The assignment operator has lower percedence than the trinary operator.
However the immediate answer to your problem is to fix the precedence issue. Here are two fixes:
1/ $test ne 'c' ? ($OPER='s') : ($OPER='c'); 2/ $OPER = $test ne 'c' ? 's' : 'c';
In reply to Re: ternary operator
by GrandFather
in thread ternary operator
by pglenski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |