my %count; while () { $count{lc $_}++ for grep { !m{^[0-9]+(\.[0-9]+)?$} } m/\w+/g; } #### $count{lc $_}++ for grep { !m{^[0-9]+$} } m/^\w+$/g;