Also, the docs for B::Deparse around the -xLEVEL option pretty much implies that ternaries and ifs are equivalent:
If *LEVEL* is at least 7, "if" statements will be translated into equivalent expressions using "&&", "?:" and "do {}"; for instance print 'hi' if $nice; if ($nice) { print 'hi'; } if ($nice) { print 'hi'; } else { print 'bye'; } turns into $nice and print 'hi'; $nice and do { print 'hi' }; $nice ? do { print 'hi' } : do { print 'bye' };
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^2: Ternary if versus normal if question
by xdg
in thread Ternary if versus normal if question
by tphyahoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |