if{ my $newfile="$file\n"; @array = grep(/\Q$newfile\E/,keys %hash); if (!@array) { push @newfiles,$newfile; #last; } next unless (@array); ..................... }