use File::Basename qw( basename ); my $opt_action; my $opt_type; my %rules = ( "create-tap" => sub { $opt_action = 'create'; $opt_type = 'domestic +'; }, ... "*" => sub { $opt_action = $_[0]; }, ); my ($verb, $object) = split(/-/, basename($0)); my $handler = $rules{"$verb-$object"} || $rules{"$verb-"} || $rules{"-$object"} || $rules{"*-}; $handler->($verb, $object) if $handler; ...process the options...
In reply to Re: Set getopt defaults based on $0
by ikegami
in thread Set getopt defaults based on $0
by samwyse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |