Getopt::Simple 1.48 review
DownloadGetopt::Simple is a Perl module that provides a simple wrapper around Getopt::Long. SYNOPSIS use Getopt::Simple;
|
|
Getopt::Simple is a Perl module that provides a simple wrapper around Getopt::Long.
SYNOPSIS
use Getopt::Simple;
# Or ...
# use Getopt::Simple qw($switch);
my($options) =
{
help =>
{
type => '',
env => '-',
default => '',
# verbose => '', # Not needed on every key.
order => 1,
},
username =>
{
type => '=s', # As per Getopt::Long.
env => '$USER', # Help text.
default => $ENV{'USER'} || 'RonSavage', # In case $USER is undef.
verbose => 'Specify the username on the remote machine',
order => 3, # Help text sort order.
},
password =>
{
type => '=s',
env => '-',
default => 'password',
verbose => 'Specify the password on the remote machine',
order => 4,
},
};
my($option) = Getopt::Simple -> new();
if (! $option -> getOptions($options, "Usage: testSimple.pl [options]") )
{
exit(-1); # Failure.
}
print "username: $$option{'switch'}{'username'}. n";
print "password: $$option{'switch'}{'password'}. n";
# Or, after 'use Getopt::Simple qw($switch);' ...
# print "username: $$switch{'username'}. n";
# print "password: $$switch{'password'}. n";
Getopt::Simple is a pure Perl module.
The Getopt::Simple module provides a simple way of specifying:
Command line switches
Type information for switch values
Default values for the switches
Help text per switch
Requirements:
Perl
Getopt::Simple 1.48 keywords