knexus has asked for the wisdom of the Perl Monks concerning the following question:
In the sample code below, the output will change depending on wheather you're using getopt() or getopts().
use strict; use Getopt::Std; our ($opt_h, $opt_a); getopt('ha'); print "help=$opt_h\n" if (defined $opt_h); print "all=$opt_a\n" if (defined $opt_a);
Results with getopt
perl -w test.pl -h -a help=-a
Results with getopts
perl -w test.pl -h -a help=1 all=1
So, at this point I know how to get what I want (use getopts). However, being a perl newbie and in learn mode, I am curious about this behavior.
Could this be a platform issue?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt: vs. Getopts confusion
by shenme (Priest) on Aug 30, 2003 at 23:26 UTC | |
by knexus (Hermit) on Aug 31, 2003 at 00:23 UTC |