Parse::CPAN::Packages::Fast - parse CPAN's package index
use Parse::CPAN::Packages::Fast; my $p = Parse::CPAN::Packages::Fast->new; ## or alternatively, if CPAN.pm is not configured: # my $p = Parse::CPAN::Packages::Fast->new("/path/to/02packages.details.txt.gz"); my $m = $p->package("Kwalify"); # $m is a Parse::CPAN::Packages::Fast::Package object print $m->package, "\n"; # Kwalify print $m->version, "\n"; # 1.21 my $d = $m->distribution; # $d is a Parse::CPAN::Packages::Fast::Distribution object print $d->dist, "\n"; # Kwalify print $d->version, "\n"; # 1.21
This is a largely API compatible rewrite of Parse::CPAN::Packages.
Notable differences are
The method add_package of Parse::CPAN::Packages::Fast::Distribution is not implemented
Parse::CPAN::Packages::Fast::Distribution is really a CPAN::DistnameInfo (but this one is compatible with Parse::CPAN::Packages::Distribution>
A Parse::CPAN::Packages::Fast::Distribution object does not have its packages included in the data structure, but it's necessary to use the contains method. Likewise, a Parse::CPAN::Packages::Fast::Package object does not include the containing distribution in the data structure, but it's necessary to use the distribution method.
contains
distribution
Calling Parse::CPAN::Packages' constructor is quite slow and takes about 10 seconds on my machine. In contrast, the reimplementation just takes a second.
Parse::CPAN::Packages
I did some benchmarking of the original module and found no obvious weak point to speed it up. Moose is used here, but does not seem to cause the problem. I suspect that the real problem is just heavy use of method calls.
Parse::CPAN::Packages, CPAN::DistnameInfo.
To install Parse::CPAN::Packages::Fast, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::CPAN::Packages::Fast
CPAN shell
perl -MCPAN -e shell install Parse::CPAN::Packages::Fast
For more information on module installation, please visit the detailed CPAN module installation guide.