#!/usr/bin/perl
use strict;
use CPAN::Dependency;
use YAML qw(DumpFile);

my $cpandep = new CPAN::Dependency process => ALL_CPAN;
$cpandep->verbose(1);
$cpandep->run;
my %score = $cpandep->score_by_dists;

print "Top 10 modules\n";
my @dists = sort { $score{$b} <=> $score{$a} } keys %score;
for my $dist (@dists[0..9]) {
    printf "%5d %s\n", $score{$dist}, $dist;
}

unlink('deps.yml');
DumpFile('deps.yml', $cpandep->deps_by_dists);
unlink('score.yml');
DumpFile('score.yml', \%score);
