NAME

paramHash Module with functions to convert to/from CGI-params and a HASH.

SYNOPSIS

use paramHash;
use CGI;

my $c=CGI->new();

my $h=param2Hash($c,"PARAMSSTARTWITHTHIS");

my $html=hash2Html($h,"STARTPARAMSWITHTHIS");

DESCRIPTION

Module that offers conversion functions to/from CGI-param and a HASH.

All functions are exported by default, so no need to instantiate, import or refer to module (besides a Use-statement);

CGI parameter names should be just characters (a-zA-Z) and/or numbers (0-9) and no special characters. Please also be aware that underscore ("_") is not allowed in the CGI parameter name, since that is reserved as hierarchical separator for keys in the hash when transformed into HTML hidden-statements.

METHODS

param2Hash()

Converts CGI-params to a HASH.

The method takes these parameters in the following order: CGI-reference, base, array. The CGI-reference is the reference to the CGI-instance that are used in order to be able to fetch params coming in from the web-browser. The "base" defines the start-string from how the data in the web application are encoded. The "array" parameter sets if the last characters after an underscore "_" in a parameter name is only digits if that is to be intepreted as a element number in an array or not? The default is true which interprets this as element numbers in an array and puts the value-part of the param into an array. If the "array" parameter is set to false, the last characters after an underscore in the parameter name is interpreted as a subkey.

Upon success returns a HASH with the key and values of the params starting with the specified base.

hash2Html()

Convert a HASH into HTML hidden input statements.

The function takes the following parameters in this order: HASH-reference, base.

The HASH-reference is the HASH to convert to HTML hidden input statements. The base- parameter specified what the hidden input statements are to start with.

Upon success returns the HTML-encoded version of the HASH-reference. This text can be included in forms in order to contain/remember all values involved.