Use a dispatch table, a hash with your commands as keys and code references as values,
my %dispatch = ( start => sub { my @args = @_; # . . . }, # . . . ); while (<STDIN>) { my ($cmd, @args) = split; exists $dispatch{$cmd} or warn 'Unknown command: ', $cmd and next; $dispatch{$cmd}(@args); }
After Compline,
Zaxo
In reply to Re: how to deal with 20 commands
by Zaxo
in thread how to deal with 20 commands
by bahadur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |