open (INTER, "file_1.txt") || die "File not found"; while (defined ($row = )) { if ($row=~ /$m$names[$k]$m$/g)) { if ($row ne $mytext) { $mytext=$mytext.$row; print " $row\n"; } } } close INTER; }