c has asked for the wisdom of the Perl Monks concerning the following question:
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:use Getopt::Std;
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?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 }
humbly -c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looking for an easier way
by rchiav (Deacon) on Jul 18, 2001 at 20:48 UTC | |
by runrig (Abbot) on Jul 18, 2001 at 21:25 UTC | |
by c (Hermit) on Jul 18, 2001 at 20:59 UTC |