.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Parse::CPAN::Packages 3pm" .TH Parse::CPAN::Packages 3pm "2022-06-16" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Parse::CPAN::Packages \- Parse 02packages.details.txt.gz .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Parse::CPAN::Packages; \& \& # must have downloaded \& my $p = Parse::CPAN::Packages\->new("02packages.details.txt.gz"); \& # either a filename as above or pass in the contents of the file \& # (uncompressed) \& my $p = Parse::CPAN::Packages\->new($packages_details_contents); \& \& my $m = $p\->package("Acme::Colour"); \& # $m is a Parse::CPAN::Packages::Package object \& print $m\->package, "\en"; # Acme::Colour \& print $m\->version, "\en"; # 1.00 \& \& my $d = $m\->distribution(); \& # $d is a Parse::CPAN::Packages::Distribution object \& print $d\->prefix, "\en"; # L/LB/LBROCARD/Acme\-Colour\-1.00.tar.gz \& print $d\->dist, "\en"; # Acme\-Colour \& print $d\->version, "\en"; # 1.00 \& print $d\->maturity, "\en"; # released \& print $d\->filename, "\en"; # Acme\-Colour\-1.00.tar.gz \& print $d\->cpanid, "\en"; # LBROCARD \& print $d\->distvname, "\en"; # Acme\-Colour\-1.00 \& \& # all the package objects \& my @packages = $p\->packages; \& \& # all the distribution objects \& my @distributions = $p\->distributions; \& \& # the latest distribution \& $d = $p\->latest_distribution("Acme\-Colour"); \& is($d\->prefix, "L/LB/LBROCARD/Acme\-Colour\-1.00.tar.gz"); \& is($d\->version, "1.00"); \& \& # all the latest distributions \& my @distributions = $p\->latest_distributions; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Comprehensive Perl Archive Network (\s-1CPAN\s0) is a very useful collection of Perl code. It has several indices of the files that it hosts, including a file named \*(L"02packages.details.txt.gz\*(R" in the \&\*(L"modules\*(R" directory. This file contains lots of useful information and this module provides a simple interface to the data contained within. .PP In a future release Parse::CPAN::Packages::Package and Parse::CPAN::Packages::Distribution might have more information. .SS "Methods" .IX Subsection "Methods" .IP "new" 4 .IX Item "new" Creates a new instance from a details file. .Sp The constructor can be passed either the path to the \&\f(CW\*(C`02packages.details.txt.gz\*(C'\fR file, a path to an ungzipped version of this file, or a scalar containing the entire uncompressed contents of the file. .Sp Note that this module does not concern itself with downloading this file. You should do this yourself. For example: .Sp .Vb 3 \& use LWP::Simple qw(get); \& my $data = get("http://www.cpan.org/modules/02packages.details.txt.gz"); \& my $p = Parse::CPAN::Packages\->new($data); .Ve .Sp If you have a configured \s-1CPAN\s0, then there's usually already a cached file available: .Sp .Vb 5 \& use CPAN; \& $CPAN::Be_Silent = 1; \& CPAN::HandleConfig\->load; \& my $file = $CPAN::Config\->{keep_source_where} . "/modules/02packages.details.txt.gz"; \& my $p = Parse::CPAN::Packages\->new($file); .Ve .IP "package($packagename)" 4 .IX Item "package($packagename)" Returns a \f(CW\*(C`Parse::CPAN::Packages::Package\*(C'\fR that represents the named package. .Sp .Vb 2 \& my $p = Parse::CPAN::Packages\->new($gzfilename); \& my $package = $p\->package("Acme::Colour"); .Ve .IP "\fBpackages()\fR" 4 .IX Item "packages()" Returns a list of \fBParse::CPAN::Packages::Package\fR objects representing all the packages that were extracted from the file. .IP "\fBpackage_count()\fR" 4 .IX Item "package_count()" Returns the number of packages stored. .IP "distribution($filename)" 4 .IX Item "distribution($filename)" Returns a \fBParse::CPAN::Packages::Distribution\fR object that represents the filename passed: .Sp .Vb 2 \& my $p = Parse::CPAN::Packages\->new($gzfilename); \& my $dist = $p\->distribution(\*(AqL/LB/LBROCARD/Acme\-Colour\-1.00.tar.gz\*(Aq); .Ve .IP "\fBdistributions()\fR" 4 .IX Item "distributions()" Returns a list of \fBParse::CPAN::Packages::Distribution\fR objects representing all the known distributions. .IP "\fBdistribution_count()\fR" 4 .IX Item "distribution_count()" Returns the number of distributions stored. .IP "latest_distribution($distname)" 4 .IX Item "latest_distribution($distname)" Returns the \f(CW\*(C`Parse::CPAN::Packages::Distribution\*(C'\fR object that represents the latest distribution for the named disribution passed, that is to say it returns the distribution that has the highest version number (as determined by version.pm or number comparison if that fails): .Sp .Vb 2 \& my $p = Parse::CPAN::Packages\->new($gzfilename); \& my $dist = $p\->distribution(\*(AqAcme\-Color\*(Aq); .Ve .IP "\fBlatest_distrbutions()\fR" 4 .IX Item "latest_distrbutions()" Returns a list of \fBParse::CPAN::Packages::Distribution\fR objects representing all the latest distributions. .IP "\fBlatest_distribution_count()\fR" 4 .IX Item "latest_distribution_count()" Returns the number of distributions stored. .SS "Preamble Methods" .IX Subsection "Preamble Methods" These methods return the information from the preamble at the start of the file. They return undef if for any reason no matching preamble line was found. .IP "\fBfile()\fR" 4 .IX Item "file()" .PD 0 .IP "\fBurl()\fR" 4 .IX Item "url()" .IP "\fBdescription()\fR" 4 .IX Item "description()" .IP "\fBcolumns()\fR" 4 .IX Item "columns()" .IP "\fBintended_for()\fR" 4 .IX Item "intended_for()" .IP "\fBwritten_by()\fR" 4 .IX Item "written_by()" .IP "\fBline_count()\fR" 4 .IX Item "line_count()" .IP "\fBlast_updated()\fR" 4 .IX Item "last_updated()" .PD .SS "Addtional Methods" .IX Subsection "Addtional Methods" These are additional methods that you may find useful. .IP "parse($filename)" 4 .IX Item "parse($filename)" Parses the filename. Works in a similar fashion to the the constructor (i.e. you can pass it a filename for a compressed/1uncompressed file, a uncompressed scalar containing the file. You can also pass nothing to indicate to load the compressed file from the current working directory.) .Sp Note that each time this function is run the packages and distribtions found will be \f(CW\*(C`added\*(C'\fR to the current list of packages. .ie n .IP "add_quick($package_name, $package_version, $prefix)" 4 .el .IP "add_quick($package_name, \f(CW$package_version\fR, \f(CW$prefix\fR)" 4 .IX Item "add_quick($package_name, $package_version, $prefix)" Quick way of adding a new package and distribution. .IP "add_package($package_obj)" 4 .IX Item "add_package($package_obj)" Adds a package. Note that you'll probably want to add the corrisponding distribution for that package too (it's not done automatically.) .IP "add_distribution($distribution_obj)" 4 .IX Item "add_distribution($distribution_obj)" Adds a distribution. Note that you'll probably want to add the corresponding packages for that distribution too (it's not done automatically.) .IP "distribution_from_prefix($prefix)" 4 .IX Item "distribution_from_prefix($prefix)" Returns a distribution given a prefix. .IP "latest_distributions" 4 .IX Item "latest_distributions" Returns all the latest distributions: .Sp .Vb 1 \& my @distributions = $p\->latest_distributions; .Ve .SH "AUTHOR" .IX Header "AUTHOR" Leon Brocard .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2004\-9, Leon Brocard .SH "LICENSE" .IX Header "LICENSE" This module is free software; you can redistribute it or modify it under the same terms as Perl itself. .SH "BUGS" .IX Header "BUGS" This module leaks memory as packages hold distributions and distributions hold packages. No attempt has been made to fix this as it's not anticpated that this will be used in long running programs that will dispose of the objects once created. .PP The old interface for \f(CW\*(C`new\*(C'\fR where if you passed no arguments it would look for a \f(CW\*(C`02packages.details.txt.gz\*(C'\fR in your current directory is no longer supported. .SH "TODO" .IX Header "TODO" delete_* methods. merge_into method. Documentation for other modules. .SH "SEE ALSO" .IX Header "SEE ALSO" CPAN::DistInfoname, Parse::CPAN::Packages::Writer.