Subject: | Getopt::Std getopt() function |
The documentation says that the getopt() function "sets $opt_x (where x is the switch name) to the value of the argument if an argument is expected, or 1 otherwise". I assumed that the alternate form of getopt(), where a reference to a hash is provided, would perform similarly and set the hash value to 1 where no parameter was passed. This is not the case, and is confusing. Either this behaviour should be changed, or made clear in teh documentation that the two forms of getopt() differ in behaviour.
Example:
#!perl
use Getopt::Std;
getopt('z', \%o);
print "z\n" if $o{'z'};