URI-1.35 > URI::QueryParam
URI-1.35
Other versions:
URI-1.54

名前

URI::QueryParam - Additional query methods for URIs

URI::QueryParam - URI のための追加のクエリメソッド

概要

  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";
  }

説明

Loading the URI::QueryParam module adds some extra methods to URIs that support query methods. These methods provide an alternative interface to the $u->query_form data.

URI::QueryParam モジュールを読み込むことで、 query メソッドに対応している URI にいくつかのメソッドを追加します。 これらのメソッドは $u->query_form データに対する代替インターフェースを 提供します。

The query_param_* methods have deliberately been made identical to the interface of the corresponding CGI.pm methods.

query_param_* メソッドは、対応する CGI.pm メソッドの インターフェースと故意に同じにしています。

The following additional methods are made available:

次の追加のメソッドが利用可能です:

@keys = $u->query_param
@values = $u->query_param( $key )
$first_value = $u->query_param( $key )
$u->query_param( $key, $value,... )

If $u->query_param is called with no arguments, it returns all the distinct parameter keys of the URI. In a scalar context it returns the number of distinct keys.

$u->query_param が引数なしで呼び出されると、 URI の全ての異なるパラメータキーを返します。 スカラコンテキストでは、異なるキーの数を返します。

When a $key argument is given, the method returns the parameter values with the given key. In a scalar context, only the first parameter value is returned.

$key 引数が与えられると、このメソッドは与えられたキーの パラメータ値を返します。 スカラコンテキストでは、最初のパラメータ値のみが返されます。

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.

追加の引数が与えられると、これらは指定されたキーの それぞれのパラメータを更新するために使われます。 提供された値のどれかが配列リファレンスの場合、 配列は実際の値を得るためにデリファレンスされます。

$u->query_param_append($key, $value,...)

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:

与えられたキーに対して、そのキーの古いパラメータに触れることなく、 新しいパラメータを追加します。 これは次のもののより効率の良い版です:

   $u->query_param($key,
                   $u->query_param($key),
                   $value,...);

One difference is that this expression would return the old values of $key, whereas the query_param_append() method does not.

一つの違いは、この式は $key の古い値を返しますが、 query_param_append() メソッドはそうではないことです。

@values = $u->query_param_delete($key)
$first_value = $u->query_param_delete($key)

Deletes all key/value pairs with the given key. The old values are returned. In a scalar context, only the first value is returned.

与えられたキーに関する全てのキー/値を削除します。 以前の値が返されます。 スカラコンテキストでは、最初の値のみが返されます。

Using the query_param_delete() method is slightly more efficient than the equivalent:

query_param_delete() メソッドを使うことは、 次の等価物よりやや効率の良いものです:

   $u->query_param($key, []);
$hashref = $u->query_form_hash
$u->query_form_hash( \%new_form )

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.

クエリ形式のキー/値の組を表現するハッシュへのリファレンスを返します。 キーが複数回現れる場合、ハッシュ値は配列リファレンスになります。

Note that sequence information is lost. This means that:

並びの情報は失われることに注意してください。 つまり次のものは:

   $u->query_form_hash($u->query_form_hash)

is not necessarily a no-op, as it may reorder the key/value pairs. The values returned by the query_param() method should stay the same though.

キー/値の組の順序が変わるかもしれないので、 必ずしも何もしないわけではありません。 しかし、query_param() メソッドで返される値は、 同じのままのはずです。

SEE ALSO

URI, CGI

コピーライト

Copyright 2002 Gisle Aas.