Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Set getopt defaults based on $0

by ikegami (Patriarch)
on Jan 13, 2011 at 17:56 UTC ( [id://882188]=note: print w/replies, xml ) Need Help??


in reply to Set getopt defaults based on $0

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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://882188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-23 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found