NAME

Getopt::EX::LabeledParam - Labeled parameter handling

SYNOPSIS

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);

DESCRIPTION

This module implements the super class of Getopt::EX::Colormap.

Parameters can be given in two ways: one as a labeled table, and one as an indexed list.

The handler maintains hash and list objects, and labeled values are stored in the hash, while non-label values are in the list automatically. Users can mix both specifications.

When the value field has a special form of a function call, a Getopt::EX::Func object is created and stored for that entry. See the "FUNCTION SPEC" section in Getopt::EX::Colormap for more details.

HASH

Basically, labeled parameter is defined by LABEL=VALUE notation:

FILE=R

Definitions can be connected by commas (,):

FILE=R,LINE=G

Multiple labels can be set for same value:

FILE=LINE=TEXT=R

Wildcards * and ? can be used in label names, and they match existing hash key names. If labels OLD_FILE and NEW_FILE exist in the hash,

*FILE=R

and

OLD_FILE=NEW_FILE=R

produces the same result.

If the VALUE part starts with a plus (+) character, it is appended to the current value. At this time, the CONCAT string is inserted before the additional string. The default CONCAT string is empty, so use the configure method to set it. If the VALUE part starts with a minus (-) character, the following characters are deleted from the current value.

LIST

If the LABEL= part is omitted, values are treated as an anonymous list and stored in the 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 by label.

METHODS

new
configure
HASH => hashref
LIST => listref

HASH and LIST references can be set by the new or configure method. You can provide default settings for the hash and list, and it is usually easier to access those values directly rather than through class methods.

NEWLABEL => 0/1

By default, load_params does not create a new entry in the hash table, and absent labels are ignored. Setting the NEWLABEL parameter to true makes it possible to create a new hash entry.

CONCAT => string

Set the concatenation string inserted before appending a string.

RESET => string

Set the reset mark. Undefined by default. If this reset string is found in a list-type argument, the list is reset to empty.

load_params option

Load the option list into the object.

append HASHREF or LIST

Provides a simple interface to append a colormap hash or color list. If a hash reference is given, all entries of the hash are appended to the colormap. Otherwise, they are appended to the anonymous color list.

SEE ALSO

Getopt::EX::Colormap

# LocalWords: CONCAT hashref listref NEWLABEL HASHREF colormap