keys#

Synopsis#

my @k = keys %hash;
my $count = keys %hash;         # scalar context: number of keys
for my $key (keys %hash) { ... }

Description#

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

In list context, pushes all keys of the hash onto the stack as individual string values. In scalar context, returns the number of key-value pairs. Accepts both %hash and $hashref (auto- dereferences). As a side effect, resets the hash’s internal iterator used by each.

See also#

values, each, exists, delete