foreach my $line (@words) { $line =~ tr/A-Z/a-z/; foreach my $ignore (@ignore) { $line =~ s/\b$ignore\b//g; } }