use strict; use warnings; open(my $text, "ue1.txt"); my $result = ""; my $count = 0; while (<$text>){ $result .= $_; } my $line = ; foreach my $wert ($result) { if ($wert =~/$line/) { $count++; } } print $count; ausgegeben wird hier dann 0, da Count ja auf null gesetzt wurde. ich wollte aber eigentlich das die Count variable immer um 1 erhöht wird, sobald das Wort im text gefunden wurde.