Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: RFC Getopt::Hash

by radiantmatrix (Parson)
on Aug 09, 2005 at 18:15 UTC ( #482347=note: print w/replies, xml ) Need Help??


in reply to Re^3: RFC Getopt::Hash
in thread RFC Getopt::Hash

I believe it is already done: Getopt::Mixed. The syntax is slightly different from Getopt::Long, so it isn't a drop-in replacement. Also, by default, it exports a bunch of scalars into the calling package (bad, IMO) -- the non-default behavior is pretty nice, though:

use Getopt::Mixed 'nextOption'; Getopt::Mixed::init('option1=s>o', 'option2:i>o2'); my %opt = ( option1 => 'default1', option2 => 'default2', ); while ( my ($k, $v) = nextOption() ) { $opt{$k} = $v } Getopt::Mixed::cleanup(); ## what's left is now in @ARGV

Using nextOption lets you process serially, too, which can be nice sometimes.

<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://482347]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-04-26 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?