more useful options | |
PerlMonks |
Re^2: Code blocks with ternary operator or trailing conditionalsby puterboy (Scribe) |
on Feb 09, 2014 at 15:36 UTC ( [id://1074131]=note: print w/replies, xml ) | Need Help?? |
Indeed, I have tried these in the past -- but: 1. The 'and' method requires one to be very careful about return values -- making sure you have the logic right the first time and that the logic never changes or has exceptions (as you and others have pointed out). 2. The comma method is great (and even works with the ternary operator, if you use parentheses similar to how you did when using 'and'). However, this only works with scalar statements and can create real issues/confusion with operators that can operate on lists (like print). So thanks for showing these options -- even though I have mostly shied away from them -- due to the syntax/grammer issues you and others have raised. Thanks!!!
In Section
Seekers of Perl Wisdom
|
|