281 lines
4.5 KiB
HTML
281 lines
4.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of URI::QueryParam</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>URI::QueryParam</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-08<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
URI::QueryParam - Additional query methods for URIs
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use URI;
|
|
use URI::QueryParam;
|
|
|
|
$u = URI->new("", "http");
|
|
$u->query_param(foo => 1, 2, 3);
|
|
print $u->query; # prints foo=1&foo=2&foo=3
|
|
|
|
for my $key ($u->query_param) {
|
|
print "$key: ", join(", ", $u->query_param($key)), "\n";
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
Loading the <TT>"URI::QueryParam"</TT> module adds some extra methods to
|
|
URIs that support query methods. These methods provide an alternative
|
|
interface to the <TT>$u</TT>->query_form data.
|
|
<P>
|
|
|
|
The query_param_* methods have deliberately been made identical to the
|
|
interface of the corresponding <TT>"CGI.pm"</TT> methods.
|
|
<P>
|
|
|
|
The following additional methods are made available:
|
|
<DL COMPACT>
|
|
<DT id="1">@keys = $u->query_param<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="2">@values = $u->query_param( $key )<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="3">$first_value = $u->query_param( $key )<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="4">$u->query_param( $key, $value,... )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
If <TT>$u</TT>->query_param is called with no arguments, it returns all the
|
|
distinct parameter keys of the <FONT SIZE="-1">URI.</FONT> In a scalar context it returns the
|
|
number of distinct keys.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
When a <TT>$key</TT> argument is given, the method returns the parameter values with the
|
|
given key. In a scalar context, only the first parameter value is
|
|
returned.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If additional arguments are given, they are used to update successive
|
|
parameters with the given key. If any of the values provided are
|
|
array references, then the array is dereferenced to get the actual
|
|
values.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Please note that you can supply multiple values to this method, but you cannot
|
|
supply multiple keys.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Do this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$uri->query_param( widget_id => 1, 5, 9 );
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Do <FONT SIZE="-1">NOT</FONT> do this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$uri->query_param( widget_id => 1, frobnicator_id => 99 );
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="5">$u->query_param_append($key, $value,...)<DD>
|
|
|
|
|
|
|
|
|
|
Adds new parameters with the given
|
|
key without touching any old parameters with the same key. It
|
|
can be explained as a more efficient version of:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$u->query_param($key,
|
|
$u->query_param($key),
|
|
$value,...);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
One difference is that this expression would return the old values
|
|
of <TT>$key</TT>, whereas the <B>query_param_append()</B> method does not.
|
|
<DT id="6">@values = $u->query_param_delete($key)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="7">$first_value = $u->query_param_delete($key)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Deletes all key/value pairs with the given key.
|
|
The old values are returned. In a scalar context, only the first value
|
|
is returned.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Using the <B>query_param_delete()</B> method is slightly more efficient than
|
|
the equivalent:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$u->query_param($key, []);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="8">$hashref = $u->query_form_hash<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="9">$u->query_form_hash( \%new_form )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Returns a reference to a hash that represents the
|
|
query form's key/value pairs. If a key occurs multiple times, then the hash
|
|
value becomes an array reference.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note that sequence information is lost. This means that:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$u->query_form_hash($u->query_form_hash);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
is not necessarily a no-op, as it may reorder the key/value pairs.
|
|
The values returned by the <B>query_param()</B> method should stay the same
|
|
though.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">URI</FONT>, <FONT SIZE="-1">CGI</FONT>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright 2002 Gisle Aas.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="10"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="11"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="12"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="13"><A HREF="#lbAE">SEE ALSO</A><DD>
|
|
<DT id="14"><A HREF="#lbAF">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:59 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|