In one of scripts, wanted to add facilty to set options via configfile alongside getting it from cmdline.
I looked at bunch of different ways to set options using configfile and cmdline.
- simple perl file read for configfile and use of getOpt::Long for cmdline options
- AppConfig for both configfile and cmdline args
- configReader:: Did not dwell much into it
I am leaning towards 1) since it is simple and does what I want.
Now main question:
one thing that I did not like in all of them was the fact that you had to deal with same varible three times.
- first, you declare the variable
- then, you pass it as Hash to the function that reads it ..
- then, again deal with same variable in the usage()...
Is there a way I have to deal with the variable just once??
I took a brief look at GetOpt::Declare() and It seems that helps reduce the dealings to twice ...But then it is not as powerful as AppConfg and does not allow reading files...
Any smart way to reduce dealing with variables ?
Thoughts on ways to read arguments via configfile also welcome/appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.