perl_mystery has asked for the wisdom of the Perl Monks concerning the following question:

For some reason with the below code,I am not getting the options given on command line,every option has the value "1",any idea?

use Getopt::Long; use Data::Dumper; my %options = (); #my %options = ('des' => \$des, 'a' => \$a, 'd' => \$d, 'r' => \$r, 'v +' => \$v); GetOptions (\%options, 'des', 'a', 'd', 'r', 'v'); print Dumper( \%options ); OUTPUT:- $VAR1 = { 'v' => 1, 'des' => 1, 'a' => 1, 'r' => 1, 'd' => 1 };

Replies are listed 'Best First'.
Re: Getopt::Long error
by ambrus (Abbot) on Mar 10, 2011 at 08:01 UTC

    I can't reproduce that result. I get $VAR1 = {}; when I run your code. (I'm using perl v5.12.3 on amd64-linux with Getopt::Long 2.38).

Re: Getopt::Long error
by Anonymous Monk on Mar 10, 2011 at 00:54 UTC
    Options are taken to be flags (state indicated by their presence, and taking no argument) without being specified like 'foo=i' or 'foo=s'. Please read the module's documentation.