values - return a list of the values in a hash


NAME

values - return a list of the values in a hash


SYNOPSIS

values HASH


DESCRIPTION

Returns a list consisting of all the values of the named hash. (In a scalar context, returns the number of values.)

The values are returned in an apparently random order. The actual random order is subject to change in future versions of perl, but it is guaranteed to be the same order as either the keys or each function would produce on the same (unmodified) hash. Since Perl 5.8.1 the ordering is different even between different runs of Perl for security reasons (see Algorithmic Complexity Attacks in the perlsec manpage).

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

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

See also keys, each, and sort.

 values - return a list of the values in a hash