foreach my $wd (@words) { $wd =~ s/[[:punct:]]+$//; next if length($wd) < 5; $count{$wd}++; }