in reply to Good Style for Small Apps
sub add { print "added\n"; } sub remove { print "removed\n"; } my $dt = { 'add' => \&add , 'remove' => \&remove }; my $cmd = "add"; if (defined $dt->{$cmd}) { $dt->{$cmd}(); } else { print "command not found: ", $cmd, "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Good Style for Small Apps
by Anonymous Monk on Jun 22, 2015 at 18:00 UTC |