1Parse::CPAN::Packages::UFsaesrt(C3o)ntributed Perl DocumPeanrtsaet:i:oCnPAN::Packages::Fast(3)
2
3
4
6 Parse::CPAN::Packages::Fast - parse CPAN's package index
7
9 use Parse::CPAN::Packages::Fast;
10
11 my $p = Parse::CPAN::Packages::Fast->new("/path/to/02packages.details.txt.gz");
12 ## Or alternatively, if CPAN.pm is configured
13 #my $p = Parse::CPAN::Packages::Fast->new;
14
15 my $m = $p->package("Kwalify");
16 # $m is a Parse::CPAN::Packages::Fast::Package object
17 print $m->package, "\n"; # Kwalify
18 print $m->version, "\n"; # 1.21
19
20 my $d = $m->distribution;
21 # $d is a Parse::CPAN::Packages::Fast::Distribution object
22 print $d->dist, "\n"; # Kwalify
23 print $d->version, "\n"; # 1.21
24
26 This is a largely API compatible rewrite of Parse::CPAN::Packages.
27
28 Notable differences are
29
30 · The method add_package of Parse::CPAN::Packages::Fast::Distribution
31 is not implemented
32
33 · Parse::CPAN::Packages::Fast::Distribution is really a
34 CPAN::DistnameInfo (but this one is compatible with
35 Parse::CPAN::Packages::Distribution>
36
37 · A Parse::CPAN::Packages::Fast::Distribution object does not have
38 its packages included in the data structure, but it's necessary to
39 use the "contains" method. Likewise, a
40 Parse::CPAN::Packages::Fast::Package object does not include the
41 containing distribution in the data structure, but it's necessary
42 to use the "distribution" method.
43
44 · The "new" constructor may be called without the path to the
45 "02packages.details.txt" file. In this case CPAN.pm's logic is used
46 to find an existing packages file. Note that this might be
47 interactive (i.e. if CPAN.pm was never configured, or needs
48 reconfiguration), so don't do this in batch systems.
49
50 WHY?
51 Calling "Parse::CPAN::Packages"' constructor is quite slow and takes
52 about 10 seconds on my machine. In contrast, the reimplementation just
53 takes a second.
54
55 I did some benchmarking of the original module and found no obvious
56 weak point to speed it up. Moose is used here, but does not seem to
57 cause the problem. I suspect that the real problem is just heavy use of
58 method calls.
59
60 Also, this module does not have problems with circular references like
61 the original. See "BUGS" in Parse::CPAN::Packages.
62
64 Parse::CPAN::Packages, CPAN::DistnameInfo.
65
66
67
68perl v5.30.0 2019-07-26 Parse::CPAN::Packages::Fast(3)