Three conditions may not be enough to warrant this, but it's also possible to construct the Perlish equivilant of a SWITCH statement.
perlsyn goes into detail on loop and block control, which are the building blocks you use within Perl to hand-roll a switch construct. Or for the daring souls you can also
use Switch; ...see
Switch for details on that. Beware that
Switch documentation states, "
There are undoubtedly serious bugs lurking somewhere in code this funky." So in production code you're probably better off creating your own switch construct as described in
perlsyn.
Sometimes logical short circuit operators or trinary operators can make the code more readable (and sometimes less, so use good judgement). They're discussed in perlop, though I see you're already using '&&' as a logical operator. Just remember that it can be used to control program flow too.
Update: Added quote from the Switch documentation as recommended by Enlil.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.