grep -l 002389983 * | xargs grep -l 29994339499 #### open my $fh, "<", $File::Find::name or die; my ($f1, $f2); while (<$fh>) { $f1 ||= /02389983/; $f2 ||= /29994339499/; last if $f1 && $f2; } if ($f1 && $f2) { ... Both patterns found ... }