A dispatch table is a neat way to do that. It is a hash, keyed by your input string, with code references as values.
my %action = ( go => sub { # some code }, turn => \&turn_sub, #... } while (1) { my $act = <>; chomp $act; # parsing can get fancier here exists $action{$act} and $action{$act}->(); }
After Compline,
Zaxo
In reply to Re: Naming Subs
by Zaxo
in thread Naming Subs
by eoin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |