In the the three solutions that where posted, everyone uses 'exists $hash{key}' and a '$hash{key}=...' and to me these look like two look-ups in the hash to me. Is this efficient? Can this be more efficient?
Athanasius
++$count{$word} if exists $count{$word};Tux
$cnt{$_}++ for grep { exists $cnt{$_} } m/(\w+)/g;AnomalousMonk
exists $count{$_} and ++$count{$_} for $line =~ m{ $rx_word }xmsg;In reply to Re: Count number of occurrences of a list of words in a file
by Veltro
in thread Count number of occurrences of a list of words in a file
by Azaghal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |