Use a regular expression match. See perlretut.
In reply to Re: Limit long words and numbers by GrandFather in thread Limit long words and numbers by htmanning