http://www.perlmonks.org?node_id=475819


in reply to Top five words by occurrence

Have you heard of the Unix program called uniq?

It might help you here. (You can also pipe its output to a perl one-liner if you need more flexability.)