- or download this
$num_keys = scalar keys %hash;
- or download this
$number = grep(//, keys %hash);
for (keys %hash) { $number++; }
- or download this
## Find the number of elements that are defined:
...
## Find the number of elements where the key equals the value:
$number = grep($_ eq $hash{$_}, keys %hash);