Apache2-API
view release on metacpan or search on metacpan
lib/Apache2/API/Query.pm view on Meta::CPAN
$qq->revert->strip('foo')->replace(bar => 123);
Note that Apache2::API::Query stashes a copy of the parameter set that existed at construction time, so that any changes made by these methods can be rolled back using 'revert()'. So you don't (usually) need to keep multiple copies around to handle i...
=over 4
=item revert()
Revert the current parameter set back to that originally given at construction time i.e. discard all changes made since construction.
=item strip($param1, $param2, ...)
Remove all occurrences of the given parameters and their values from the current parameter set.
=item strip_except($param1, $param2, ...)
Remove all parameters EXCEPT those given from the current parameter
set.
=item strip_null()
Remove all parameters that have a value of undef from the current
parameter set.
=item replace($param1 => $value1, $param2, $value2, ...)
Replace the values of the given parameters in the current parameter set with these new ones. Parameter names must be scalars, but values can be either scalars or arrayrefs of scalars, when multiple values are desired.
Note that 'replace' can also be used to add or append, since there's no requirement that the parameters already exist in the current parameter
set.
=item strip_like($regex)
Remove all parameters whose names match the given (qr-quoted) regex e.g.
$qq->strip_like(qr/^utm/)
Does NOT match against parameter values.
=item separator($separator)
Set the argument separator to use for output. Default: '&'.
=back
=head2 ACCESSOR METHODS
=over 4
=item has_changed()
If the query is actually changed by any of the modifier methods (strip, strip_except, strip_null, strip_like, or replace) it sets an internal changed flag which can be access by:
$qq->has_changed
revert() resets the has_changed flag to false.
=back
=head2 OUTPUT METHODS
=over 4
=item "$qq", stringify(), stringify($separator)
Return the current parameter set as a conventional param=value query string, using $separator as the separator if given. e.g.
foo=1&bar=2&bar=3
Note that all parameters and values are URI escaped by stringify(), so that query-string reserved characters do not occur within elements. For instance, a parameter set of:
'group' => 'prod,infra,test'
'op:set' => 'x=y'
will be stringified as:
group=prod%2Cinfra%2Ctest&op%3Aset=x%3Dy
=item qstringify(), qstringify($separator)
Convenience method to stringify with a leading '?' e.g.
?foo=1&bar=2&bar=3
=item hash()
Return a hash (in list context) or hashref (in scalar context) of the current parameter set. Single-item parameters have scalar values, while while multiple-item parameters have arrayref values e.g.
{
foo => 1,
bar => [ 2, 3 ],
}
=item hash_arrayref()
Return a hash (in list context) or hashref (in scalar context) of the current parameter set. All values are returned as arrayrefs, including those with single values e.g.
{
foo => [ 1 ],
bar => [ 2, 3 ],
}
=item hidden()
Returns the current parameter set as a concatenated string of hidden input tags, one per parameter-value e.g.
<input type="hidden" name="foo" value="1" />
<input type="hidden" name="bar" value="2" />
<input type="hidden" name="bar" value="3" />
=back
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 CREDITS
Gavin Carr <gavin@openfusion.com.au> for his version of L<URI::Query>
( run in 2.365 seconds using v1.01-cache-2.11-cpan-56fb94df46f )