CPAN::Dependency is a Perl module that can process a set of distributions, up to the whole CPAN, and extract the dependency relations between these distributions. Alternatively, it can load the prerequisites information from a CPANTS database.
It also calculates a score for each distribution based on the number of times it appears in the prerequisites of other distributions. The algorithm is described in more details in "SCORE CALCULATION".
CPAN::Dependency stores the data in an internal structure which can be saved and loaded using save_deps_tree() and load_deps_tree(). The structure looks like this:
DEPS_TREE = {
DIST => {
author => STRING,
cpanid => STRING,
score => NUMBER,
prereqs => {
DIST => BOOLEAN,
...
},
used_by => {
DIST => BOOLEAN,
...
},
},
....
}
With each distribution name DIST are associated the following fields:
* author is a string which contains the name of the author who wrote (or last released) this distribution;
* cpanid is a string which contains the CPAN ID of the author who wrote (or last released) this distribution;
* score is a number which represents the score of the distribution;
* prereqs is a hashref which represents the prerequisites of the distribution; each key is a prerequisite name and its value is a boolean which is true when the distribution and the prerequisite are not from the same author;
* used_by is a hashref which represents the distributions which use this particular distribution; each key is a distribution name and its value is a boolean which is true when both distributions are not from the same author.
SYNOPSIS
Find and print the 10 most required CPAN distributions by stand-alone processing.
use CPAN::Dependency;
my $cpandep = CPAN::Dependency->new(process => ALL_CPAN);
$cpandep->run; # this may take some time..
$cpandep->calculate_score;
my %score = $cpandep->score_by_dists;
my @dists = sort { $score{$b} $score{$a} } keys %score;
print "Top 10 modules
";
for my $dist (@dists[0..9]) {
printf "] %s
", $score{$dist}, $dist;
}
Same thing, but this time by loading the prerequisites information from the CPANTS database.
use CPAN::Dependency;
my $cpandep = new CPAN::Dependency;
$cpandep->load_cpants_db(file => 'cpants.db');
$cpandep->calculate_score;
my %score = $cpandep->score_by_dists;
my @dists = sort { $score{$b} $score{$a} } keys %score;
print "Top 10 modules
";
for my $dist (@dists[0..9]) {
printf "] %s
", $score{$dist}, $dist;
}
Product's homepage
Requirements:
· Perl