mrborisguy has asked for the wisdom of the Perl Monks concerning the following question:
I've started using Getopt::Long for a little script I'm creating. I'm having trouble figuring out how to give an option a default value if it is specified. For example:
shell$ progname $opt == 0 shell$ progname --opt $opt == 100 shell$ progname --opt 7 $opt == 7
Or more verbosely, if --opt isn't specified, I want it to be 0. If --opt is specified, but not given any number, I want $opt to hold 100, and if --opt is specified with a number, I want $opt to hold the number specified.
This is probably really easy, but I must be missing it. Has anybody done this before?
-Bryan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long and default number
by jimbojones (Friar) on Jul 19, 2005 at 18:41 UTC | |
by mrborisguy (Hermit) on Jul 19, 2005 at 19:06 UTC | |
|
Re: Getopt::Long and default number
by izut (Chaplain) on Jul 19, 2005 at 18:49 UTC |