in reply to Re: Re: Re: How to find the most frequent in a file?
in thread How to find the most frequent in a file?

This doesn't quite work if lines start with non-word characters such as brackets or leading spaces (as I discovered when I tried running this program on itself). If the first character(s) of the line are non-word characters then the first value returned by split is empty, and it may tell you that the most common word is the null string ('').

A quick fix is to replace your $frequency{$word}++; line with

    $frequency{$word}++ if ($word);

so the null string is ignored.