in reply to Find most frequently used word in text file.

I think there is a bug. You sort lexically, not numerically. Try this instead:
@values = sort { $a <=> $b } @values;

Tip #1 from the Basic debugging checklist: use strict and warnings. strict generates a compile error, and warnings generates these (and more):

Scalar value @values[-1] better written as $values[-1] Name "main::file" used only once: possible typo