I would like options given on the command line to have priority over all other options (i.e. those in the perl script and those in option files).
There is a option to given a option file on the command line (i.e.
--conf=file).
I need a way to parse the command line options looking for
--conf=file, if so then
do file and then parse the rest of the command line options (minus the
--conf=file). In summary, I need to handle the
--conf=file before looking at the other command line options to keep the priority correct.
my %help_options = (
"color!" => sub { $options{USE_COLOR} = $_[1] },
"conf=s" => sub { $options{CONF} = $_[1] },
);
GetOptions( %help_options );
do $options{CONF} if defined $options{CONF};
Obviously, this doesn't do what I want as the 'do' will be executed after parsing the command line options.
script.pl --conf=file --color
should always set $options{USE_COLOR} = 1 regardless of what's in file.
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.