1CPAN::DistnameInfo(3) User Contributed Perl DocumentationCPAN::DistnameInfo(3)
2
3
4
6 CPAN::DistnameInfo - Extract distribution name and version from a
7 distribution filename
8
10 my $pathname = "authors/id/G/GB/GBARR/CPAN-DistnameInfo-0.02.tar.gz";
11
12 my $d = CPAN::DistnameInfo->new($pathname);
13
14 my $dist = $d->dist; # "CPAN-DistnameInfo"
15 my $version = $d->version; # "0.02"
16 my $maturity = $d->maturity; # "released"
17 my $filename = $d->filename; # "CPAN-DistnameInfo-0.02.tar.gz"
18 my $cpanid = $d->cpanid; # "GBARR"
19 my $distvname = $d->distvname; # "CPAN-DistnameInfo-0.02"
20 my $extension = $d->extension; # "tar.gz"
21 my $pathname = $d->pathname; # "authors/id/G/GB/GBARR/..."
22
23 my %prop = $d->properties;
24
26 Many online services that are centered around CPAN attempt to associate
27 multiple uploads by extracting a distribution name from the filename of
28 the upload. For most distributions this is easy as they have used
29 ExtUtils::MakeMaker or Module::Build to create the distribution, which
30 results in a uniform name. But sadly not all uploads are created in
31 this way.
32
33 "CPAN::DistnameInfo" uses heuristics that have been learnt by
34 <http://search.cpan.org/> to extract the distribution name and version
35 from filenames and also report if the version is to be treated as a
36 developer release
37
38 The constructor takes a single pathname, returning an object with the
39 following methods
40
41 cpanid
42 If the path given looked like a CPAN authors directory path, then
43 this will be the the CPAN id of the author.
44
45 dist
46 The name of the distribution
47
48 distvname
49 The file name with any suffix and leading directory names removed
50
51 filename
52 If the path given looked like a CPAN authors directory path, then
53 this will be the path to the file relative to the detected CPAN
54 author directory. Otherwise it is the path that was passed in.
55
56 maturity
57 The maturity of the distribution. This will be either "released" or
58 "developer"
59
60 extension
61 The extension of the distribution, often used to denote the archive
62 type (e.g. 'tar.gz')
63
64 pathname
65 The pathname that was passed to the constructor when creating the
66 object.
67
68 properties
69 This will return a list of key-value pairs, suitable for assigning
70 to a hash, for the known properties.
71
72 version
73 The extracted version
74
76 Graham Barr <gbarr@pobox.com>
77
79 Copyright (c) 2003 Graham Barr. All rights reserved. This program is
80 free software; you can redistribute it and/or modify it under the same
81 terms as Perl itself.
82
83
84
85perl v5.36.0 2023-01-20 CPAN::DistnameInfo(3)