perl-5.38.0
values HASH
values ARRAY

In list context, returns a list consisting of all the values of the named hash. In Perl 5.12 or later only, will also return a list of the values of an array; prior to that release, attempting to use an array argument will produce a syntax error. In scalar context, returns the number of values.

リストコンテキストでは、指定したハッシュのすべての値を返します。 Perl 5.12 以降でのみ、配列の全ての値からなるリストも返します; このリリースの前では、配列要素に使おうとすると文法エラーが発生します。 スカラコンテキストでは、値の数を返します。

Hash entries are returned in an apparently random order. The actual random order is specific to a given hash; the exact same series of operations on two hashes may result in a different order for each hash. Any insertion into the hash may change the order, as will any deletion, with the exception that the most recent key returned by each or keys may be deleted without changing the order. So long as a given hash is unmodified you may rely on keys, values and each to repeatedly return the same order as each other. See "Algorithmic Complexity Attacks" in perlsec for details on why hash order is randomized. Aside from the guarantees provided here the exact details of Perl's hash algorithm and the hash traversal order are subject to change in any release of Perl. Tied hashes may behave differently to Perl's hashes with respect to changes in order on insertion and deletion of items.

ハッシュ要素は見かけ上、ランダムな順序で返されます。 実際のランダムな順序はハッシュに固有です; 二つのハッシュに全く同じ一連の 操作を行っても、ハッシュによって異なった順序になります。 ハッシュへの挿入によって順序が変わることがあります; 削除も同様ですが、 each または keys によって返されたもっとも 最近のキーは順序を変えることなく削除できます。 ハッシュが変更されない限り、keys, values, each が繰り返し同じ順序で返すことに依存してもかまいません。 なぜハッシュの順序がランダム化されているかの詳細については "Algorithmic Complexity Attacks" in perlsec を参照してください。 ここで保証したことを除いて、Perl のハッシュアルゴリズムとハッシュ横断順序の 正確な詳細は Perl のリリースによって変更される可能性があります。 tie されたハッシュは、アイテムの挿入と削除の順序に関して Perl のハッシュと 異なった振る舞いをします。

As a side effect, calling values resets the HASH or ARRAY's internal iterator (see each) before yielding the values. In particular, calling values in void context resets the iterator with no other overhead.

副作用として、values を呼び出すと、 値を取り出す前に HASH や ARRAY の 内部反復子(each 参照)をリセットします。 特に、values を無効コンテキストで呼び出すとその他の オーバーヘッドなしで反復子をリセットします。

Apart from resetting the iterator, values @array in list context is the same as plain @array. (We recommend that you use void context keys @array for this, but reasoned that taking values @array out would require more documentation than leaving it in.)

反復子をリセットするということを除けば、 リストコンテキストでの values @array は単なる @array と同じです。 この目的のためには無効コンテキストで keys @array を使うことを お勧めしますが、values @array を取り出すにはそのままにするよりも より多くの文書が必要だと判断しました。)

Note that the values are not copied, which means modifying them will modify the contents of the hash:

値はコピーされないので、返されたリストを変更すると ハッシュの中身が変更されることに注意してください。

    for (values %hash)      { s/foo/bar/g }  # modifies %hash values
    for (@hash{keys %hash}) { s/foo/bar/g }  # same

Starting with Perl 5.14, an experimental feature allowed values to take a scalar expression. This experiment has been deemed unsuccessful, and was removed as of Perl 5.24.

Perl 5.14 から、values がスカラ式を取ることが出来るという 実験的機能がありました。 この実験は失敗と見なされ、Perl 5.24 で削除されました。

To avoid confusing would-be users of your code who are running earlier versions of Perl with mysterious syntax errors, put this sort of thing at the top of your file to signal that your code will work only on Perls of a recent vintage:

あなたのコードを以前のバージョンの Perl で実行したユーザーが不思議な 文法エラーで混乱することを避けるために、コードが最近のバージョンの Perl で のみ 動作することを示すためにファイルの先頭に以下のようなことを 書いてください:

    use v5.12;  # so keys/values/each work on arrays

See also keys, each, and sort.

keys, each, sort も 参照してください。