Hash::Param - CGI/Catalyst::Request-like parameter-hash accessor/mutator
Version 0.04
my $params = Hash::Param->new(parameters => { qw/a 1 b 2 c 3/, d => [qw/4 5 6 7/], }) $result = $params->param( a ) # Returns 1 $result = $params->param( d ) # Returns 4 @result = $params->param( d ) # Returns 4, 5, 6, 7 @result = $params->params # Returns a, b, c, d $result = $params->params # Returns { a => , b => 2, c => 3, d => [ 4, 5, 6, 7 ] } @result = $params->params( a, b, d ) # Returns 1, 2, [ 4, 5, 6, 7 ] %result = $params->slice( a, b ) # Returns a => 1, b => 2 $params->param( a => 8 ) # Sets a to 8 $params->param( a => 8, 9 ) # Sets a to [ 8, 9 ]
Hash::Param provides a CGI-param-like accessor/mutator for a hash
Returns a new Hash::Param object with the given parameters
<params> should be a HASH reference (the object will be initialized with an empty hash if none is given)
<is> should be either ro or rw to indicate where the object is read-only or read-write, respectively
ro
rw
The object will be read-write by default
Returns the value of <param>
If the <param> value is an ARRAY reference:
Sets the value of <param> to <value>
Throws an error if $params is read-only
Sets the value of <param> to an ARRAY reference consisting of [ <value>, <value>, ... ]
Returns a list of every param name
An alias for ->param
Returns a list containing with value of each <param>
Returns an ARRAY reference in scalar context
If $params is read-only, then each ARRAY reference value will be copied first (if any)
Returns a hash of the parameters stored in $param
In scalar context, will return a HASH reference (which will be copied first if $params is read-only)
Sets the parameters of $params via <hash> (which should be a HASH reference)
An alias for ->params
Does the same as $param->param( <param> )
Does the same as $param->params( <param>, <param>, ... )
Does the same as $param->params
Returns a hash slice of <param>, <param>, ...
Returns a HASH reference in scalar context
If $params is read-only, then the slice will be cloned
Robert Krimen, <rkrimen at cpan.org>
<rkrimen at cpan.org>
You can contribute or fork this project via GitHub:
http://github.com/robertkrimen/hash-param/tree/master
git clone git://github.com/robertkrimen/hash-param.git Hash-Param
Please report any bugs or feature requests to bug-hash-param at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hash-Param. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-hash-param at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Hash::Param
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash-Param
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Hash-Param
CPAN Ratings
http://cpanratings.perl.org/d/Hash-Param
Search CPAN
http://search.cpan.org/dist/Hash-Param
Copyright 2008 Robert Krimen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Hash::Param, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hash::Param
CPAN shell
perl -MCPAN -e shell install Hash::Param
For more information on module installation, please visit the detailed CPAN module installation guide.