in reply to Another Getopt::Long questions

I believe your code does what you want. Using the following code:
use strict; use warnings; use Getopt::Long; use Data::Dumper; my %options; GetOptions( \%options, 'length|height=i', ); print Dumper \%options;
I get the following:
E:\>go.pl --height=1 $VAR1 = { 'length' => 1 }; E:\>go.pl --length=1 $VAR1 = { 'length' => 1 };

-enlil

Replies are listed 'Best First'.
Re: Re: Another Getopt::Long questions
by kelan (Deacon) on Apr 10, 2003 at 14:42 UTC

    I don't remember if it's mentioned specifically in the POD, but from my usage, the first option is always the name of the key it will use. This is handy when you want to use one character options or bundling. As in:

    use Getopt::Long; Getopt::Long::Configure('bundling'); my %options; GetOptions( \%options, 'LongName|L=s' ); if ($options{LongName}) { # do something with $options{LongName} }
    And the user can specify that option either as:
    prog.pl --longname something
    or
    prog.pl -L something

    kelan


    Perl6 Grammar Student