Q&A > hashes > How can I find the number of elements in a hash? contributed by OeufMayo
The easiest way is to have the keys function evaluated in scalar context:
%hash = ('foo'=>1, 'bar'=>3);
$count = keys %hash;
Frying pan on the stove
Results (330 votes). Check out past polls.