NAME
Getopt::EX::Long - Getopt::Long compatible extended module
SYNOPSIS
use Getopt::EX::Long;
GetOptions("file=s" => \my $file);
or using the object-oriented interface:
use Getopt::EX::Long;
my $parser = Getopt::EX::Long::Parser->new(
config => [ qw(posix_default no_ignore_case) ],
exconfig => [ BASECLASS => 'App::example' ],
);
$parser->getoptions("file=s" => \my $file);
DESCRIPTION
Getopt::EX::Long is almost fully compatible with Getopt::Long. You can replace the module declaration, and it should work the same as before (see "INCOMPATIBILITY").
In addition to standard Getopt::Long functionality, users can define their own option aliases and write dynamically loaded extension modules. If the command name is example, the file
~/.examplerc
is loaded by default. In this rc file, users can define option aliases with macro processing. This is useful when the command takes complex arguments.
Special options starting with -M load the corresponding Perl module. The module is assumed to be under a specific base class. For example:
% example -Mfoo
loads the App::example::foo module by default.
Since extension modules are normal Perl modules, users can write any code they need. If the module is specified with an initial function call, that function is called when the module is loaded:
% example -Mfoo::bar(buz=100)
This loads module foo and calls function bar with the parameter buz set to 100.
If the module includes a __DATA__ section, it is interpreted as an rc file. Combined with the startup function call, this allows module behavior to be controlled through user-defined options.
For details about rc files and module specification, see Getopt::EX::Module.
CONFIG OPTIONS
Config options are set by ExConfigure or the exconfig parameter for the Getopt::EX::Long::Parser::new method.
- AUTO_DEFAULT
-
Config options RCFILE and BASECLASS are automatically set based on the name of the command executable. If you don't want this behavior, set AUTO_DEFAULT to 0.
Other options including RCFILE and BASECLASS are passed to Getopt::EX::Loader. Read its documentation for details.
INCOMPATIBILITY
The subroutine GetOptionsFromString is not supported.