in reply to Getopt::Long and default number
Hi
I think you want the ":" signifier when identifying your options. This says the value for the option is optional. If the option is present without a value, it takes the number indicatied after the ":" ; otherwise it takes the user-supplied value. This is in the POD in the section "Summary of Option Specifications"
My test runs give:use Getopt::Long; my $opt = 0; GetOptions ("opt:100" => \$opt ); print "Opt is:\t$opt\n";
HTH - j>opt.pl --opt Opt is: 100 >opt.pl --opt 7 Opt is: 7 >opt.pl Opt is: 0
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Getopt::Long and default number
by mrborisguy (Hermit) on Jul 19, 2005 at 19:06 UTC |
In Section
Seekers of Perl Wisdom