Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re (tilly) 1: Getopt::Declare

by tilly (Archbishop)
on Feb 03, 2001 at 05:17 UTC ( #56174=note: print w/ replies, xml ) Need Help??


in reply to Getopt::Declare

Out of curiousity, what does this module do to startup times? The kinds of little utilities which I would want to use command line argument processing for tend to care about how quickly they start.

(Of course I generally find Getopt::Std perfectly acceptable...)


Comment on Re (tilly) 1: Getopt::Declare
Re: Re (tilly) 1: Getopt::Declare
by danger (Priest) on Feb 03, 2001 at 11:09 UTC

    Well, Obviously it's somewhat slower to load:

    $ time perl -MGetopt::Std -e 1 0.07user 0.00system 0:00.07elapsed 97%CPU $ time perl -MGetopt::Long -e 1 0.19user 0.05system 0:00.23elapsed 102%CPU $ time perl -MGetopt::Declare -e 1 0.59user 0.08system 0:00.67elapsed 99%CPU

    For the option parsing itself, that'll depend on how much extra work you put into the declaration (action blocks, more sophisticated parameter checking, etc.). Certainly it isn't the option-processing answer to every problem, but if it's easy to code and read and the startup/parse hit (amortized over runtime) isn't crucial, it is certainly worth looking into. It won't compete with Getopt::Std for efficiency on simple things, but there's a boatload of functionality I didn't mention -- here's the clustering example from the docs:

    For example, given the parameter specifications: -+ Swap signs -a Append mode -b Bitwise compare -c <FILE> Create new file +del Delete old file +e <NICE:i> Execute (at specified nice level) when com +plete The following command-lines (amongst others) are all exactly equivalen +t: -a -b -c newfile +e20 +del -abc newfile +dele20 -abcnewfile+dele20 -abcnewfile +e 20del

    Also: optional parameter lists, abbreviations, mutex directive (only one of a given set of options may appear on the command line). And, it can be told to parse a config file rather than @ARGV, and can return the parser object itself so you could use it to parse multiple such sources. There might even be a kitchen sink in the source somewhere, and you never know when one of those will come in handy.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-07-29 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls