6 use Getopt::Long qw(:config bundling nopermute passthrough);
13 "F|fixed!" => \$opt_F,
14 ) or die "usage: metagrep [-w] [-l] [-F] pattern\n";
16 use Cwd qw(getcwd abs_path);
20 my $pat = shift or die "usage: metagrep pattern\n";
21 $opt_F and $pat = quotemeta $pat;
22 $opt_w and $pat = "\\b$pat\\b";
26 my $mcpath = abs_path "$FindBin::Bin/../";
27 my $onmeta = $cwd =~ m{CPAN/meta[^/]+$} ? 1 : 0;
29 my @dir = grep { -d } $mcpath, $onmeta ? "dist/U" : "$mcpath/dist/U";
30 my %dir; # I don't want a file for which any path component symlinks
33 -d and $dir{$File::Find::name}++;
36 print STDERR "<$pat>\n";
43 exists $dir{$File::Find::dir} or return;
44 #print STDERR "$File::Find::dir - $_\n";
46 $seen{$File::Find::name}++ and return;
48 $File::Find::dir =~ m{^(?:$cwd/)?dist-3} and return;
50 open my $f, "<$_" or die "$File::Find::name: $!\n";
51 my $fnm = $File::Find::name;
53 for (grep /$pat/, <$f>) {