This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[UTIL] Scan each file max once
authorH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Thu, 21 Apr 2016 11:44:41 +0000 (13:44 +0200)
committerH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Thu, 21 Apr 2016 11:44:41 +0000 (13:44 +0200)
bin/metagrep

index 71dce44..277e725 100755 (executable)
@@ -40,6 +40,8 @@ find (sub {
     exists $dir{$File::Find::dir} or return;
     #print STDERR "$File::Find::dir - $_\n";
 
+    $seen{$File::Find::name}++ and return;
+
     $File::Find::dir =~ m{^(?:$cwd/)?dist-3} and return;
 
     open my $f, "<$_" or die "$File::Find::name: $!\n";
@@ -47,8 +49,8 @@ find (sub {
     $fnm =~ s{^$cwd/}{};
     for (grep /$pat/, <$f>) {
        if ($opt_l) {
-           $seen{$fnm}++ or print "$fnm\n";
-           next;
+           print "$fnm\n";
+           return;
            }
        print "$fnm:$_";
        }