values 
valuesHASHvaluesARRAY
This function returns a list consisting of all the values in
the indicated HASH. The values are returned
in an apparently random order, but it is the same order as either the
keys or each function would produce on the same hash.
Oddly, to sort a hash by its values, you usually need to use the
keys function, so see the example
under keys for that.
You can modify the values of a hash using this function because the returned list contains aliases of the values, not just copies. (In earlier versions, you needed to use a hash slice for that.)
for (@hash{keys %hash}) { s/foo/bar/g } # old way
for (values %hash) { s/foo/bar/g } # now changes valuesUsing values on a hash that is
bound to a humongous DBM file is bound to produce a humongous list,
causing you to have a humongous process. You might prefer to use the
each function, which will iterate
over the hash entries one by one without slurping them all into a single
gargantuan, er, humongous list.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access