in reply to Complex conditional statements
You can always test something like that with a one-liner.
On the other hand, statement modifiers at the end are syntactically OK; e.g. 1 or 2 if 3.% perl -wle '1 unless 2 or (3 and 4) if (5 and 6)' syntax error at -e line 1, near ") if" Execution of -e aborted due to compilation errors.
Whether it is good programming is less clear-cut.
I like using statement modifiers rather than regular if-else blocks whenever the contents of the blocks would have been short. I.e.
rather thanbar() if $foo;
And sometimes I stretch it to statements likeif ( $foo ) { bar(); }
in preference overbar() or baz() if $foo;
...but I suspect this is already inching into obfuscation.if ( $foo ) { unless ( bar() ) { baz(); } }
Great question++, BTW. I look forward to reading the responses you get.
the lowliest monk
|
|---|