CPAN::DistnameInfo(3)

πŸ’… CPAN::DistnameInfo(3) β€” the user contributed Perl doc you didn't know you needed

okay so bestie, welcome to CPAN::DistnameInfo(3), one of those User Contributed Perl Documentation gems ✨ It's the module that looks at a CPAN upload filename and goes "ah yes, I know exactly what this is" β€” and honestly? iconic behavior.


🌸 NAME 🌸

CPAN::DistnameInfo β€” literally extracts the distribution name and version out of a distribution filename. that's the whole job. she's focused. πŸ’…


✨ SYNOPSIS ✨

here's the vibe, bestie β€” you hand her a pathname, she hands you back a whole object full of answers:

  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;

like, look at her go 🫢 every single accessor just doing its thing.


πŸ¦‹ DESCRIPTION πŸ¦‹

so. many online services that are centered around CPAN try to associate multiple uploads by extracting a distribution name from the filename of the upload. and for most distributions this is easy β€” they used ExtUtils::MakeMaker or Module::Build to create the distribution, which results in a uniform name. slay for them. πŸ’–

but sadly 😭 not all uploads are created in this way. some people out here naming files like it's a creative writing exercise.

CPAN::DistnameInfo uses heuristics that have been learnt by <http://search.cpan.org/> to extract the distribution name and version from filenames β€” and she'll also report if the version is to be treated as a developer release. no cap, she's been through some things and she learned from them. 🧚

the constructor takes a single pathname, returning an object with the following methods:

  • cpanid β€” if the path given looked like a CPAN authors directory path, then this will be the the CPAN id of the author. iykyk πŸ‘‘
  • dist β€” the name of the distribution. yes, just the name. she's not doing extra.
  • distvname β€” the file name with any suffix and leading directory names removed. clean. ✨
  • filename β€” 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. either way she's got you 🫢
  • maturity β€” the maturity of the distribution. this will be either "released" or "developer". periodt. those are the two options.
  • extension β€” the extension of the distribution, often used to denote the archive type (e.g. 'tar.gz'). lowkey the most useful one ngl πŸ’€
  • pathname β€” the pathname that was passed to the constructor when creating the object. she remembers her origins. main character energy.
  • properties β€” this will return a list of key-value pairs, suitable for assigning to a hash, for the known properties. so convenient bestie πŸŽ€
  • version β€” the extracted version. the number. the moment. 🌟

🌈 AUTHOR 🌈

Graham Barr <gbarr@pobox.com> β€” we stan. πŸ’œ


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.

fr fr, same terms as Perl itself β€” don't come for her legally, she's just a little module. πŸ™ˆ

and that's the whole page, bestie! πŸ’– this little cutie is from perl v5.42.0, dated 2011-03-15, and she's still serving CPAN::DistnameInfo(3) realness to this day. mwah. πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from