Created
May 18, 2009 14:11
-
-
Save bingos/113495 to your computer and use it in GitHub Desktop.
This file contains 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
use strict; | |
use warnings; | |
use File::Fetch; | |
use File::Spec; | |
use IO::Zlib; | |
use CPAN::DistnameInfo; | |
use ExtUtils::Installed; | |
use Module::CoreList; | |
my $location = '.'; | |
my $mirror = 'http://cpan.cpantesters.org/'; | |
my @files = ('modules/02packages.details.txt.gz'); | |
foreach my $file ( @files ) { | |
my $url = join '', $mirror, $file; | |
my $ff = File::Fetch->new( uri => $url ); | |
my $stat = $ff->fetch( to => $location ); | |
next unless $stat; | |
print "Downloaded '$stat'\n"; | |
} | |
die "No packages file found\n" unless -e '02packages.details.txt.gz'; | |
print "Building in-memory CPAN database\n"; | |
my %mods_to_dist; | |
my $fh = IO::Zlib->new( '02packages.details.txt.gz', "rb" ) or die "$!\n"; | |
while (<$fh>) { | |
last if /^\s*$/; | |
} | |
while (<$fh>) { | |
chomp; | |
my ($module,$version,$package_path) = split ' ', $_; | |
$mods_to_dist{ $module } = $package_path; | |
} | |
my %dists; | |
my $inst = ExtUtils::Installed->new(); | |
foreach my $module ( $inst->modules() ) { | |
next unless exists $mods_to_dist{ $module }; | |
next if _core_module( $module ); | |
$dists{ $mods_to_dist{ $module } }++; | |
} | |
print $_, "\n" for sort keys %dists; | |
exit 0; | |
sub _core_module { | |
my $module = shift || return; | |
my $ver = shift || $]; | |
my $core = $Module::CoreList::version{ 0+$ver }->{ $module }; | |
return $core | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment