-
-
Save sugyan/9384714 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Find; | |
use File::Spec; | |
my %modules = (); | |
my %inc = map { $_ => $_ } map { File::Spec->canonpath($_) } @INC; | |
for my $path (map { File::Spec->canonpath($_) } grep { -d $_ && $_ ne '.' } @INC) { | |
find(+{ | |
wanted => sub { | |
my $name = $File::Find::fullname; | |
if (-d $name) { | |
if (exists $inc{$name} && $inc{$name} ne $path) { | |
$File::Find::prune = 1; | |
} | |
return; | |
} | |
return unless $name =~ s/\.p(?:m|od)\z//; | |
$name = File::Spec->abs2rel($name, $path); | |
my $module = join('::', File::Spec->splitdir($name)); | |
$modules{$module}++; | |
}, | |
follow => 1, | |
follow_skip => 2, | |
}, $path); | |
} | |
print "$_\n" for sort keys %modules; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment