1URI::QueryParam(3)    User Contributed Perl Documentation   URI::QueryParam(3)
2
3
4

NAME

6       URI::QueryParam - Additional query methods for URIs
7

SYNOPSIS

9         use URI;
10         use URI::QueryParam;
11
12         $u = URI->new("", "http");
13         $u->query_param(foo => 1, 2, 3);
14         print $u->query;    # prints foo=1&foo=2&foo=3
15
16         for my $key ($u->query_param) {
17             print "$key: ", join(", ", $u->query_param($key)), "\n";
18         }
19

DESCRIPTION

21       Loading the "URI::QueryParam" module adds some extra methods to URIs
22       that support query methods.  These methods provide an alternative
23       interface to the $u->query_form data.
24
25       The query_param_* methods have deliberately been made identical to the
26       interface of the corresponding "CGI.pm" methods.
27
28       The following additional methods are made available:
29
30       @keys = $u->query_param
31       @values = $u->query_param( $key )
32       $first_value = $u->query_param( $key )
33       $u->query_param( $key, $value,... )
34           If $u->query_param is called with no arguments, it returns all the
35           distinct parameter keys of the URI.  In a scalar context it returns
36           the number of distinct keys.
37
38           When a $key argument is given, the method returns the parameter
39           values with the given key.  In a scalar context, only the first
40           parameter value is returned.
41
42           If additional arguments are given, they are used to update
43           successive parameters with the given key.  If any of the values
44           provided are array references, then the array is dereferenced to
45           get the actual values.
46
47           Please note that you can supply multiple values to this method, but
48           you cannot supply multiple keys.
49
50           Do this:
51
52               $uri->query_param( widget_id => 1, 5, 9 );
53
54           Do NOT do this:
55
56               $uri->query_param( widget_id => 1, frobnicator_id => 99 );
57
58       $u->query_param_append($key, $value,...)
59           Adds new parameters with the given key without touching any old
60           parameters with the same key.  It can be explained as a more
61           efficient version of:
62
63              $u->query_param($key,
64                              $u->query_param($key),
65                              $value,...);
66
67           One difference is that this expression would return the old values
68           of $key, whereas the query_param_append() method does not.
69
70       @values = $u->query_param_delete($key)
71       $first_value = $u->query_param_delete($key)
72           Deletes all key/value pairs with the given key.  The old values are
73           returned.  In a scalar context, only the first value is returned.
74
75           Using the query_param_delete() method is slightly more efficient
76           than the equivalent:
77
78              $u->query_param($key, []);
79
80       $hashref = $u->query_form_hash
81       $u->query_form_hash( \%new_form )
82           Returns a reference to a hash that represents the query form's
83           key/value pairs.  If a key occurs multiple times, then the hash
84           value becomes an array reference.
85
86           Note that sequence information is lost.  This means that:
87
88              $u->query_form_hash($u->query_form_hash);
89
90           is not necessarily a no-op, as it may reorder the key/value pairs.
91           The values returned by the query_param() method should stay the
92           same though.
93

SEE ALSO

95       URI, CGI
96
98       Copyright 2002 Gisle Aas.
99
100
101
102perl v5.32.1                      2021-03-03                URI::QueryParam(3)
Impressum