I just found the pearl of:
use Getopt::Std;
and I am using it effectively within my code, however
I am having some issues trying to find the best way
to have the script echo a help menu when no flags are
specified.
Currently, I am using:
getopts("n:f:hc",\%option);
if (!$option{n} && !$option{f}) {
help();
exit;
}
sub help {
print<<EOF
Usage: dnsmod [ -h ] [ -n ] [ -f ]
-n <domain>
-f <corp || client >
-h print this help page
EOF
}
This works, however as I add more flag options to my
script, this could become very tedious and could cause
problems if someone other than myself plans to add
some flags of their own.
Is it possible to use $#ARGV or some other built in to
measure whether or not flags were specified such that
my test loop would not have to be updated with every
new feature stuck in future revisions of the code?
humbly -c
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.