1Parse::CPAN::Packages(3U)ser Contributed Perl DocumentatiPoanrse::CPAN::Packages(3)
2
3
4

NAME

6       Parse::CPAN::Packages - Parse 02packages.details.txt.gz
7

SYNOPSIS

9         use Parse::CPAN::Packages;
10
11         # must have downloaded
12         my $p = Parse::CPAN::Packages->new("02packages.details.txt.gz");
13         # either a filename as above or pass in the contents of the file
14         # (uncompressed)
15         my $p = Parse::CPAN::Packages->new($packages_details_contents);
16
17         my $m = $p->package("Acme::Colour");
18         # $m is a Parse::CPAN::Packages::Package object
19         print $m->package, "\n";   # Acme::Colour
20         print $m->version, "\n";   # 1.00
21
22         my $d = $m->distribution();
23         # $d is a Parse::CPAN::Packages::Distribution object
24         print $d->prefix, "\n";    # L/LB/LBROCARD/Acme-Colour-1.00.tar.gz
25         print $d->dist, "\n";      # Acme-Colour
26         print $d->version, "\n";   # 1.00
27         print $d->maturity, "\n";  # released
28         print $d->filename, "\n";  # Acme-Colour-1.00.tar.gz
29         print $d->cpanid, "\n";    # LBROCARD
30         print $d->distvname, "\n"; # Acme-Colour-1.00
31
32         # all the package objects
33         my @packages = $p->packages;
34
35         # all the distribution objects
36         my @distributions = $p->distributions;
37
38         # the latest distribution
39         $d = $p->latest_distribution("Acme-Colour");
40         is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
41         is($d->version, "1.00");
42
43         # all the latest distributions
44         my @distributions = $p->latest_distributions;
45

DESCRIPTION

47       The Comprehensive Perl Archive Network (CPAN) is a very useful collec‐
48       tion of Perl code. It has several indices of the files that it hosts,
49       including a file named "02packages.details.txt.gz" in the "modules"
50       directory. This file contains lots of useful information and this mod‐
51       ule provides a simple interface to the data contained within.
52
53       In a future release Parse::CPAN::Packages::Package and
54       Parse::CPAN::Packages::Distribution might have more information.
55
56       Methods
57
58       new Creates a new instance from a details file.
59
60           The constructor can be passed either the path to the "02pack‐
61           ages.details.txt.gz" file, a path to an ungzipped version of this
62           file, or a scalar containing the entire uncompressed contents of
63           the file.
64
65           Note that this module does not concern itself with downloading this
66           file. You should do this yourself.  For example:
67
68              use LWP::Simple qw(get);
69              my $data = get("http://www.cpan.org/modules/02packages.details.txt.gz");
70              my $p = Parse::CPAN::Packages->new($data);
71
72       package($packagename)
73           Returns a "Parse::CPAN::Packages::Package" that represents the
74           named package.
75
76             my $p = Parse::CPAN::Distribution->new($gzfilename);
77             my $package = $p->package("Acme::Colour");
78
79       packages()
80           Returns a list of Parse::CPAN::Packages::Package objects represent‐
81           ing all the packages that were extracted from the file.
82
83       package_count()
84           Returns the numebr of packages stored.
85
86       distribution($filename)
87           Returns a Parse::CPAN::Distribution that represents the filename
88           passed:
89
90             my $p = Parse::CPAN::Distribution->new($gzfilename);
91             my $dist = $p->distribution('L/LB/LBROCARD/Acme-Colour-1.00.tar.gz');
92
93       distrbutions()
94           Returns a list of Parse::CPAN::Distribution objects representing
95           all the known distributions.
96
97       distribution_count()
98           Returns the number of distributions stored.
99
100       latest_distribution($distname)
101           Returns the "Parse::CPAN::Distribution" that represents the latest
102           distribution for the named disribution passed, that is to say it
103           returns the distribution that has the highest version number (as
104           determined by version.pm or number comparison if that fails):
105
106             my $p = Parse::CPAN::Distribution->new($gzfilename);
107             my $dist = $p->distribution('Acme-Color');
108
109       latest_distrbutions()
110           Returns a list of Parse::CPAN::Distribution objects representing
111           all the latest distributions.
112
113       latest_distribution_count()
114           Returns the number of distributions stored.
115
116       Addtional Methods
117
118       These are additional methods that you may find useful.
119
120       parse($filename)
121           Parses the filename.  Works in a similar fashion to the the con‐
122           structor (i.e. you can pass it a filename for a compressed/1uncom‐
123           pressed file, a uncompressed scalar containing the file.  You can
124           also pass nothing to indicate to load the compressed file from the
125           current working directory.)
126
127           Note that each time this function is run the packages and distrib‐
128           tions found will be "added" to the current list of packages.
129
130       add_quick($package_name, $package_version, $prefix)
131           Quick way of adding a new package and distribution.
132
133       add_package($package_obj)
134           Adds a package.  Note that you'll probably want to add the cor‐
135           risponding distribution for that package too (it's not done auto‐
136           matically.)
137
138       add_distribution($distribution_obj)
139           Adds a distribution.  Note that you'll probably want to add the
140           corrisponding packages for that distribution too (it's not done
141           automatically.)
142

AUTHOR

144       Leon Brocard <acme@astray.com>
145
147       Copyright (C) 2004, Leon Brocard
148
149       This module is free software; you can redistribute it or modify it
150       under the same terms as Perl itself.
151

BUGS

153       This module leaks memory as packages hold distributions and distribu‐
154       tions hold packages.  No attempt has been made to fix this as it's not
155       anticpated that this will be used in long running programs that will
156       dispose of the objects once created.
157
158       The old interface for "new" where if you passed no arguments it would
159       look for a "02packages.details.txt.gz" in your current directory is no
160       longer supported.
161

TODO

163       delete_* methods.  merge_into method.  Documentation for other modules.
164

SEE ALSO

166       CPAN::DistInfoname, Parse::CPAN::Packages::Writer.
167
168
169
170perl v5.8.8                       2007-04-18          Parse::CPAN::Packages(3)
Impressum