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       $u->query_param_append($key, $value,...)
48           Adds new parameters with the given key without touching any old
49           parameters with the same key.  It can be explained as a more
50           efficient version of:
51
52              $u->query_param($key,
53                              $u->query_param($key),
54                              $value,...);
55
56           One difference is that this expression would return the old values
57           of $key, whereas the query_param_append() method does not.
58
59       @values = $u->query_param_delete($key)
60       $first_value = $u->query_param_delete($key)
61           Deletes all key/value pairs with the given key.  The old values are
62           returned.  In a scalar context, only the first value is returned.
63
64           Using the query_param_delete() method is slightly more efficient
65           than the equivalent:
66
67              $u->query_param($key, []);
68
69       $hashref = $u->query_form_hash
70       $u->query_form_hash( \%new_form )
71           Returns a reference to a hash that represents the query form's
72           key/value pairs.  If a key occurs multiple times, then the hash
73           value becomes an array reference.
74
75           Note that sequence information is lost.  This means that:
76
77              $u->query_form_hash($u->query_form_hash);
78
79           is not necessarily a no-op, as it may reorder the key/value pairs.
80           The values returned by the query_param() method should stay the
81           same though.
82

SEE ALSO

84       URI, CGI
85
87       Copyright 2002 Gisle Aas.
88
89
90
91perl v5.16.3                      2012-03-11                URI::QueryParam(3)
Impressum