Changes in version 2.38

Changes in version 2.37

Changes in version 2.36

**************** WARNING -- EXPERIMENTAL CODE AHEAD ****************

use Getopt::Long qw(GetOptionsFromArray); $ret = GetOptionsFromArray(\@myopts, ...);

use Getopt::Long qw(GetOptionsFromString); $ret = GetOptionsFromString($optstring, ...);

Note that upon completion, no arguments may remain in the string. If arguments may remain, call it in list context:

($ret, $args) = GetOptionsFromString($optstring, ...);

@$args will have the remaining arguments.

**************** END EXPERIMENTAL CODE ****************

Changes in version 2.35

foo.pl /option=value

instead of forcing people to use the short option style

foo.pl /option value

This enhancement was suggested and implemented by Yves Orton.

--coordinates 52.2 16.4 --rgbcolor 255 255 149

To handle the above command line, the following call to GetOptions can be used:

GetOptions('coordinates=f{2}' => \@coor, 'rgbcolor=i{3}' => \@color);

You can specify the minimum and maximum number of values desired. The syntax for this is similar to that of regular expression patterns: { min , max }.

Changes in version 2.34

        @ARGV = qw(--foo=xx);
        GetOptions("foo=s@", \$var);
        # Now $var->[0] eq "xx"

Changes in version 2.33

The following new features are marked experimental. This means that if you are going to use them you must watch out for the next release of Getopt::Long to see if the API has changed.

Both subroutines take the same arguments as Pod::Usage::pod2usage, see its documentation for details.

Example

use Getopt::Long 2.33 qw(GetOptions HelpMessage); GetOptions(...) or HelpMessage(2);

Changes in version 2.32

Changes in version 2.31

Changes in version 2.30

Changes in version 2.29

Changes in version 2.28

Changes in version 2.27

Changes in version 2.26

Changes in version 2.25

Changes in version 2.24

use Getopt::Long;
$p = new Getopt::Long::Parser;
$p->configure(...configuration options...); if ($p->getoptions(...options descriptions...)) ...

use Getopt::Long qw(:config no_ignore_case bundling);

Changes in version 2.23

Changes in version 2.22

"foo!" => \$opt_foo, "f" => \$opt_foo or

"foo|f" => \$opt_foo, "nofoo" => sub { $opt_foo = 0 }

Remember that this is only required when bundling is in effect.

Changes in version 2.21

Changes in version 2.20

Changes in version 2.19

There's no version 2.18

Changes in version 2.17

     my $more = 2;
     Getopt::Long::Configure("bundling");
     GetOptions ("v+" => \$more);
     print STDOUT ("more = $more\n");

will print "more = 3" when called with "-v", "more = 4" when called with "-vv" (or "-v -v"), and so on.

     perl Makefile.PL
     make
     make test
     make install

Changes in version 2.16

This version is identical to 2.15, which was not released.

There's no version 2.14

Changes in version 2.13

Changes in version 2.12

GetOptions ("help|?", ...)

Changes in version 2.11

{ package Foo;

sub new () { return bless {}; } }

my $linkage = Foo->new();

GetOptions ($linkage, ... );

Changes in version 2.9

Getopt::Long::config ("no_auto_abbrev", "ignore_case");

Configuring by using the module local variables is deprecated, but it will continue to work for backwark compatibility.

Changes in version 2.6

Changes in version 2.4

--define foo=bar

and have $opt_define{"foo"} set to "bar".

Possible incompatibility in version 2.4

Previous versions of Getopt::Long always downcased the option variable names when ignorecase was in effect. This bug has been corrected. As a consequence, &GetOptions ("Foo") will now set variable $opt_Foo instead of $opt_foo.