my %words; my @blacklist_entries = qw(insurance Sxx porn buy viagra ZENIC Möbelkauf Bußgeld Führerschein); my %rx_tab = map {$_ => qr:(^|\b)\Q$_\E(\b|$):} map {lc} @blacklist_entries; while (my $line = lc ) { study $line; foreach my $k (keys %rx_tab) { $words{$k}++ while ($line =~ /$rx_tab{$k}/g); } } while (my ($key, $value) = each %words) { print "$key=$value\n"; }