my %ACTION_NAMED = define_actions(); my $action = shift; # First argument my @args = @ARGV; # Remaining arguments if (exists $ACTION_NAMED{$action}) { $ACTION_NAMED{$action}->(@args); } else { $ACTION_NAMED{_default_}->(@args); } sub define_actions { return ( action1 => \&action1, action2 => \&action2, _default_ => \&usage, ); } sub action1 { ... } sub action2 { ... } sub usage { ... }