Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

values

Returns all values of a hash, or the number of values in scalar context.

In list context, pushes all values of the hash onto the stack. In scalar context, returns the number of key-value pairs (same as keys in scalar context). Accepts both %hash and $hashref. Resets the hash’s internal iterator as a side effect.

When the REF flag is set (foreach aliasing context from the native parser), values are pushed onto the stack and the hash plus its keys are recorded for write-back of $_ modifications during iteration.

Synopsis

my @v = values %hash;
my $count = values %hash;       # scalar context: number of values
for my $val (values %hash) { ... }

See Also

keys, each, exists, delete