#!/usr/bin/perl
use strict;
use CPAN::Dependency;

my $file = shift || 'cpants.db';

my $cpandep = new CPAN::Dependency;
print "loading $file...\n";
$cpandep->load_cpants_db(file => $file);
print "calculating score...\n";
$cpandep->calculate_score;
print "saving YAML file...\n";
$cpandep->save_deps_tree(file => 'deps.yml');

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