Glivter: Further to haukex's reply:
In certain cases, I find ? : ternary chains (update: I've also seen them referred to as "ladders") very neat, clear, readable and maintainable, and useful:
my $result =
CONDITION1 ? EXPRESSION1 : # "if" case
CONDITION2 ? EXPRESSION2 : # "elsif" case
CONDITION3 ? EXPRESSION3 : # ditto
... # and so on...
die "no condition met... " # "else" default case
;
And, of course, you don't have to
die or take any other drastic action in the default case, but simply return a default value. Your
EXPRESSION can also be a side-effect-possessing
do { ... } expression or subroutine call that returns a meaningful value. (A
do-block or subroutine call always returns a value, but if you don't design it right, that value may be surprising.)
Give a man a fish: <%-{-{-{-<