Use a dispatch table. Something like...
my $mystring = "hello, I'm key2"; my %dispatcher = ( key1 => sub { print "1" }, key2 => sub { print "2" }, #... ); #... for my $key ( keys %dispatcher ) { $dispatcher{$key}->(), last if index($mystring, $key) >= 0; }
In reply to Re: if or switch?
by FunkyMonk
in thread if or switch?
by gw1500se
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |