shemp has asked for the wisdom of the Perl Monks concerning the following question:
By my understanding, blah is a required integer value, but when i invoke my script without a blah arg, i still get a true result:use strict; use warnings; use Getopt::Long; { my $blah; my $result = GetOptions('blah=i' => \$blah); print "result = $result\n"; print "blah = $blah\n"; }
perl -w getopt_test.pl
result = 1
Use of uninitialized value in concatenation (.) or string at getopt_test.pl line 12.
blah =
It makes sense that $blah is uninitialized, but i thought that $result would be false.
When i invoke this with a blah option, i get a true result also:
perl -w getopt_test.pl --blah 4
result = 1
blah = 4
As a side note:
By my understanding, i dont need to say --blah=4, i can say --blah 4, and that seems to parse correctly by my test runs.
So what am i missing here?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long result issue
by Sidhekin (Priest) on Sep 07, 2004 at 16:03 UTC | |
|
Re: Getopt::Long result issue
by Random_Walk (Prior) on Sep 07, 2004 at 16:07 UTC | |
|
Re: Getopt::Long result issue
by herveus (Prior) on Sep 07, 2004 at 16:06 UTC | |
|
Re: Getopt::Long result issue
by Zaxo (Archbishop) on Sep 07, 2004 at 16:13 UTC | |
|
Re: Getopt::Long result issue
by perlfan (Parson) on Sep 07, 2004 at 18:15 UTC |