use strict; use warnings; my $BEL_LETTERS = qr/ABVHD/; my @all_words = qw(tak het hen toj tah tam tym); ... while (my $next_line = <$FH>) { foreach my $next_word (@all_words) { my $count_words = ($next_line =~ s/\b($next_word[$BEL_LETTERS]*)\b/>$1