Thanks. This is only part of my code. There are actually 25 conditions.
If I use the "and" operator , is there a limit on how large my expression can be?
| [reply] |
| [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] |