No, but if you have 25 conditions, there's almost certainly some different way of doing it. For further help, describe how those conditions are determined, and how
the data to which it's being compared is determined. I'm sure there's a pony in there
somewhere.
-- Randal L. Schwartz, Perl hacker | [reply] |
If you're trying to test 25 different variables, I'm at a loss. If you can somehow get all the conditions into a few variables, you can construct a switch-like statement.
While there's no switch construct in perl there are many ways to construct one. My favorite is to use a single-iteration "for" loop, straight from the 2nd Edition Camel:
for( $value )
{
/matchthis/ and do{ something(); last;};
($_ > 42) and do{ something_else(); last;};
default();
}
so long as the first term in an entry in the for loop returns a boolean value, you don't need to limit yourself to strict equality operations, which is a real bonus in my eyes over the conventional switch statement found in other languages.
update: If you can't get it down to one variable, but can get it down to two or three, you can always put another one of these pseudo-switches inside one of the do blocks. | [reply] [d/l] [select] |