Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
go ahead... be a heretic
 
PerlMonks  

Re: Getopt::Long via. Hashes

by karlgoethebier (Deacon)
on May 26, 2013 at 19:53 UTC ( #1035338=note: print w/ replies, xml ) Need Help??


in reply to Getopt::Long via. Hashes

«There are a total of about 30 different (and unique) options, some taking a value, some that are just bools.»

Perhaps you should consider to use a config file instead of using so many options on the command line?

Ok, there is a lot of stuff that uses so many options on the command line (e.g. tools for processing audio, video and graphics a.s.o) but IMHO this isn't really fun.

Please take a look at Config::Tiny, XML::Simple and all that related stuff.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»


Comment on Re: Getopt::Long via. Hashes
Re^2: Getopt::Long via. Hashes
by vsespb (Hermit) on May 26, 2013 at 20:03 UTC

    That would introduce same problems - you have lot's of options as hash, and not sure how to process them...

    Also some application prefer to allow any option to be used in config or in command line

      Also some application prefer to allow any option to be used in config or in command line

      Are there any fine exemplars of exactly this kind of Perl program on PerlMonks? I've been looking for a well-written Perl program that demonstrates the best way to use either a core module or a battle-tested CPAN module to permit the user to specify many arguments to the program either on the command line or in a config file—whichever she prefers.

      Jim

        Are there any fine exemplars of exactly this kind of Perl program on PerlMonks?
        No, I am not aware of
        either a core module or a battle-tested CPAN module to permit
        to the program either on the command line or in a config file
        No, my program above permits it, but use custom libraries.

        I think you actually can write such code by yourself. It's easy to parse config and use it as default source, when a command line option is missing. And for command line you can use GetOpts. Looks like it can fit to 20 lines of code.

        However if you want error handling, multiple encodings support, complex config file(s) structure, unit tests for this, etc, it can require times more coding.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-04-21 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls