open(my $IN,'<'.$f) || die "Can not open file $datei: $!"; while(<$IN>){ $n=$n+1; printf "$n.)$_"; foreach $t (@searchstring) { if ($_=~/$t/i) { print "\nfound in $f in $z\n\n" } else { #print "\nnot found $t in $_\n" } } } close $IN;