Here's how ternary operators can be chained. (And yes, wrapping this up in a subroutine is a very good idea, but the operator chain itself could be in-lined.)
See Conditional Operator in perlop.c:\@Work\Perl>perl -wMstrict -le "my $s = qq{a ${ \str('tilt2') } operation needs @{[ str('x') ]} help} +; print qq{'$s'}; ;; sub str { my ($s) = @_; ;; return $s eq 'level3' ? 'level3 stage' : $s eq 'tilt2' ? 'tilt2 snafu' : ! defined $s ? 'undefined' : qq{Edit '$s'} ; } " 'a tilt2 snafu operation needs Edit 'x' help'
In reply to Re: perl syntax help for ternary operator
by AnomalousMonk
in thread perl syntax help for ternary operator
by ghosh123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |