11 Mar 2011 23:39:53 UTC
- Distribution: CPAN-DistnameInfo
- Module version: 0.12
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Issues (4)
- Testers (17746 / 5 / 0)
- KwaliteeBus factor: 1
- 91.20% Coverage
- License: perl_5
- Activity24 month
- Download (14.18KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
CPAN::DistnameInfo - Extract distribution name and version from a distribution filename
my $pathname = "authors/id/G/GB/GBARR/CPAN-DistnameInfo-0.02.tar.gz"; my $d = CPAN::DistnameInfo->new($pathname); my $dist = $d->dist; # "CPAN-DistnameInfo" my $version = $d->version; # "0.02" my $maturity = $d->maturity; # "released" my $filename = $d->filename; # "CPAN-DistnameInfo-0.02.tar.gz" my $cpanid = $d->cpanid; # "GBARR" my $distvname = $d->distvname; # "CPAN-DistnameInfo-0.02" my $extension = $d->extension; # "tar.gz" my $pathname = $d->pathname; # "authors/id/G/GB/GBARR/..." my %prop = $d->properties;
Many online services that are centered around CPAN attempt to associate multiple uploads by extracting a distribution name from the filename of the upload. For most distributions this is easy as they have used ExtUtils::MakeMaker or Module::Build to create the distribution, which results in a uniform name. But sadly not all uploads are created in this way.
CPAN::DistnameInfouses heuristics that have been learnt by http://search.cpan.org/ to extract the distribution name and version from filenames and also report if the version is to be treated as a developer release
The constructor takes a single pathname, returning an object with the following methods
If the path given looked like a CPAN authors directory path, then this will be the the CPAN id of the author.
The name of the distribution
The file name with any suffix and leading directory names removed
If the path given looked like a CPAN authors directory path, then this will be the path to the file relative to the detected CPAN author directory. Otherwise it is the path that was passed in.
The maturity of the distribution. This will be either
The extension of the distribution, often used to denote the archive type (e.g. 'tar.gz')
The pathname that was passed to the constructor when creating the object.
This will return a list of key-value pairs, suitable for assigning to a hash, for the known properties.
The extracted version
Graham Barr <email@example.com>
Copyright (c) 2003 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install CPAN::DistnameInfo, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install CPAN::DistnameInfo
For more information on module installation, please visit the detailed CPAN module installation guide.