in reply to Frequency of words in text file and hashes
You're doing the counts just right (but you may want to translate punctuation before splitting). You only need to manipulate the hash a bit to get what you want. Taking keys of the hash will give you the list of distinct words, which can be sorted by their value in %count:
You can translate punctuation in just one statement by putting all the punctuation characters in the first slot and using the /d switch.my @wordlist = sort {$count{$b} <=> $count{$a}} keys %count; print 'The text contains ', scalar(@wordlist), ' distinct words', "\n" +; print "$_\t$count{$_}\n" for @wordlist;
After Compline,
Zaxo
|
|---|