Getopt::EX::LabeledParam - Labeled parameter handling
GetOptions('colormap|cm:s' => @opt_colormap); # default values my %colormap = ( FILE => 'DR', LINE => 'Y', TEXT => '' ); my @colors = qw( /544 /545 /445 /455 /545 /554 ); require Getopt::EX::LabeledParam; my $cmap = Getopt::EX::LabeledParam ->new( NEWLABEL => 0, HASH => \%colormap, LIST => \@colors ) ->load_params(@opt_colormap);
This module implements super class of Getopt::EX::Colormap.
Parameters can be given in two ways: one in labeled table, and one in indexed list.
Handler maintains hash and list objects, and labeled values are stored in hash, non-label values are in list automatically. User can mix both specifications.
When the value field has a special form of function call, Getopt::EX::Func object is created and stored for that entry. See "FUNCTION SPEC" section in Getopt::EX::Colormap for more detail.
Basically, labeled parameter is defined by LABEL=VALUE notation:
FILE=R
Definition can be connected by comma (,):
,
FILE=R,LINE=G
Multiple labels can be set for same value:
FILE=LINE=TEXT=R
Wildcard * and ? can be used in label name, and they matches existing hash key name. If labels OLD_FILE and NEW_FILE exists in hash,
*
?
OLD_FILE
NEW_FILE
*FILE=R
and
OLD_FILE=NEW_FILE=R
produces same result.
If VALUE part start with plus (+) character, it is appended to current value. At this time, CONCAT string is inserted before additional string. Default CONCAT strings is empty, so use configure method to set. If VALUE part start with minus (-) character, following characters are deleted from the current value.
+
CONCAT
-
If LABEL= part is omitted, values are treated anonymous list and stored in list object. For example,
R,G,B,C,M,Y
makes six entries in the list. The list object is accessed by index, rather than label.
HASH and LIST reference can be set by new or configure method. You can provide default setting of hash and list, and it is usually easier to access those values directly, rather than through class methods.
By default, load_params does not create new entry in hash table, and absent label is ignored. Setting <NEWLABEL> parameter true makes it possible create a new hash entry.
Set concatenation string inserted before appending string.
Load option list into the object.
Provide simple interface to append colormap hash or color list. If a hash reference is given, all entry of the hash is appended to the colormap. Otherwise, they are appended anonymous color list.
Getopt::EX::Colormap
# LocalWords: CONCAT hashref listref NEWLABEL HASHREF colormap
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.