If they are very different, then a dispatch table or a Perl6 switch statement is about the most efficient.
If the code for all three cases is very similar, then perhaps this can be made to work for you:
if (m/key(\d)/) { # $1 contains the digit following "key" print "Found key followed by a $1\n" $count{$1}++; print "Total times this key was seen: ", $count{$1}, "\n"; ... }
In reply to Re: if or switch?
by pc88mxer
in thread if or switch?
by gw1500se
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |