my @woerter = qw(Wort1 Wort2); while my $line (<$fh>) { next if $line !~ m{\S}; for my $wort (@woerter) { $line =~ s{\b$wort\b}{}g; } print $line; }