Getopt::EX::Loader - RC/Module loader
use Getopt::EX::Loader; my $loader = Getopt::EX::Loader->new( BASECLASS => 'App::example', ); $loader->load_file("$ENV{HOME}/.examplerc"); $loader->deal_with(\@ARGV); my $parser = Getopt::Long::Parser->new; $parser->getoptions(... , $loader->builtins); or $parser->getoptions(\%hash, ... , $loader->hashed_builtins(\%hash));
This is the main interface to use Getopt::EX modules. You can create loader object, load user defined rc file, load modules specified by command arguments, substitute user defined option and insert default options defined in rc file or modules, get module defined built-in option definition for option parser.
Most of work is done in deal_with method. It parses command arguments and load modules specified by -M option by default. Then it scans options and substitute them according to the definitions in rc file or modules. If RC and modules defines default options, they are inserted to the arguments.
deal_with
Module can define built-in options which should be handled option parser. They can be taken by builtins method, so you should give them to option parser.
builtins
If option values are stored in a hash, use hashed_builtins with the hash reference. Actually, builtins works even for hash storage in the current version of Getopt::Long module, but it is not documented.
hashed_builtins
If App::example is given as a BASECLASS of the loader object, it is prepended to all module names. So command line
App::example
BASECLASS
% example -Mfoo
will load App::example::foo module.
App::example::foo
In this case, if module App::example::default exists, it is loaded automatically without explicit indication. Default module can be used just like a startup RC file.
App::example::default
Define the name of startup file.
Define the base class for user defined module. Use array reference to specify multiple base classes; they are tried to be loaded in order.
Define the module option string. String -M is set by default.
Define default module name. String default is set by default. Set undef if you don't want load any default module.
undef
Default true, and parse module options given to deal_with method. When disabled, module option in command line argument is not processed, but module option given in rc or module files are still effective.
Default false, and process dies when given module was not found on the system. When set true, program ignores not-existing module and stop parsing at the point leaving the argument untouched.
Return loaded Getopt::EX::Module object list.
Load specified file.
Load specified module.
To install Getopt::EX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Getopt::EX
CPAN shell
perl -MCPAN -e shell install Getopt::EX
For more information on module installation, please visit the detailed CPAN module installation guide.