NAME

Parameter::Variable - Class to define a variable in the Parameter-classes.

SYNOPSIS

 use Parameter::Variable;

 # instantiate
 my $v=Parameter::Variable->new(name=>"myvariable",value=>"myvalue",regex=>"\\w+");
 # get value
 my $val=$v->value();
 # set value
 my $v->value("myNewValue");
 # get as string
 my $s=$v->toString();
 

DESCRIPTION

Class to define a variable in the Parameter-classes. It can contain a value and a set of attributes of that value.

Current attributes (besides what it inherits from the Parameter-class): value, required and regex.

CONSTRUCTOR

new()

Sets up the parameter-classes and returns an instance of the class.

It accepts the following options:

This method is inherited from the Parameter-class. Please refer to that class for more in-depth documenation of the new()-constructor.

Returns an instance of the Parameter::Variable-class.

METHODS

regex()

Get or set the regex of the variable.

In the case of set accepts one input: regex. It must be a valid perl regex-expression.

It does not check the regex or do anything with it besides storing it. It is up to the user of the Parameter-class to check and enforce the regex.

In both get and set scenarios returns the current regex-value for the variable.

required()

Get or set the required attribute of the variable.

In the case of set accepts one input: required. 1 means true, 0 means false. If none was set for the variable in the first place it defaults to 0.

In both get and set scenarios returns the current required-value for the variable.

sandbox()

Get or set the sandbox attribute on the variable.

In the case of set accepts one parameter: sandbox. 1 means true, 0 means false. Default is 0 (false).

What sandbox means is up to the user of the class to define and enforce. The Parameter-classes does not define or enforce it.

In both get and set scenarios returns the current sandbox-value for the variable.

preEscape()

Get or set pre-escape attribute on the variable.

In the case of set accepts one parameter: preescape. 1 means true, 0 means false. Default is 1 (true).

The preescape-value is only used if escape() has been set to true. In any other case it is ignored. What the preescape-value means is that in the case of escaping, there shall be no backslashes in the beginning of the string. These are removed when calling the toString()-method of this class.

In both get and set scenarios returns the current preescape-value for the variable.

toHash()

Return all the attributes of the variable as a hash.

Accepts no input.

Returns the following as a HASH-reference:

toHash => (
            name => SCALAR,
            value => SCALAR,
            regex => SCALAR,
            private => SCALAR,
            required => SCALAR,
            escape => SCALAR,
            preescape => SCALAR,
            quote => SCALAR
          )

toString()

Convert the variable into a string.

Accepts no input.

Returns the value of the variable as a string, escaped and quoted according to the settings of the variable.

value()

Set or get the value of the variable.

In the case of set, accepts one input: value.

In both set and get scenarios returns the current value of the variable.