Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: -x accepts up to 3 additional arguments

by Codon (Friar)
on Jun 23, 2005 at 19:22 UTC ( [id://469489]=note: print w/replies, xml ) Need Help??


in reply to Re: -x accepts up to 3 additional arguments
in thread -x accepts up to 3 additional arguments

I think this is the closest to a "best solution" compared to some the others listed. Define a callback handler for your options such as:

my $flag, @args; my %more = ( x => 2, y => 1, z => 0 ); GetOptions( 'x=s' => \&parse_opt, 'y=s' => \&parse_opt, 'z=s' => \&parse_opt, ); sub parse_opt { my ($opt, $val) = @_; # splice additional args off @ARGV based on how many I expect push @args, $val, splice @ARGV, 0, $more{$opt}, (); }

Of course, all of this is going to depend on what you want to do with things later and on whether then number of params that -x and -y take varies, etc.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-29 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found