DEV Community

loading...
Cover image for CPAN utils

CPAN utils

Tib
403 Forbidden
・3 min read

CPAN utils

In this post I will present you some must-have-but-less-known CPAN utils πŸ‘ πŸ’ͺ 😎

  1. List outdated modules
  2. List latest changes
  3. Print dependencies tree
  4. List system requirements

List outdated modules

You can use cpan-outdated to get the list of your outdated modules.

$ cpan-outdated -p
Acme::Automatix
Alien::Plotly::Orca
Alien::SNMP::MAXTC
PPIx::QuoteLike
PPIx::Regexp
Enter fullscreen mode Exit fullscreen mode

Outdated modules you said?

The discrepancy is totally normal, since modules versions evolve on CPAN but not necessarily locally.

In my example, the list is very small because I updated all my modules very recently with cpan-outdated -p | cpanm (I don't really know why I did it but it was cool πŸ˜€).

Get latest changes

Use cpan-listchanges to get meaningful portions of changelog between the version installed locally versus the latest version on CPAN. Example with one of the outdated from my previous list:

$ cpan-listchanges PPIx::QuoteLike
=== Changes between 0.015 and 0.016 for PPIx-QuoteLike

0.016       2021-03-26  T. R. Wyant
    Add rt.cpan.org back to bug reporting methods. Long live RT!

    Get prerequisites up to snuff, and add xt/author/prereq.t to ensure
    they stay that way.

    Refactor authortest into three, so I do not have to generate stub
    files to test without optional modules.
Enter fullscreen mode Exit fullscreen mode

Print dependencies tree

Print the dependency tree with cpandeps

$ cpandeps JSON::Conditional
JSON::Conditional (dist: L/LN/LNATION/JSON-Conditional-1.00.tar.gz)
  JSON (dist: I/IS/ISHIGAKI/JSON-4.03.tar.gz)
    Test::More (dist: E/EX/EXODIST/Test-Simple-1.302183.tar.gz)
      File::Temp (dist: E/ET/ETHER/File-Temp-0.2311.tar.gz)
        Carp (dist: X/XS/XSAWYERX/Carp-1.50.tar.gz)
          Exporter (dist: T/TO/TODDR/Exporter-5.74.tar.gz)
          IPC::Open3 (dist: S/SH/SHAY/perl-5.32.1.tar.gz)
        File::Path (dist: J/JK/JKEENAN/File-Path-2.18.tar.gz)
          File::Spec::Functions (dist: X/XS/XSAWYERX/PathTools-3.75.tar.gz)
            Scalar::Util (dist: P/PE/PEVANS/Scalar-List-Utils-1.55.tar.gz)
        parent (dist: C/CO/CORION/parent-0.238.tar.gz)
      Storable (dist: X/XS/XSAWYERX/Storable-3.15.tar.gz)
        XSLoader (dist: S/SA/SAPER/XSLoader-0.24.tar.gz)
  Module::Metadata (dist: E/ET/ETHER/Module-Metadata-1.000037.tar.gz)
    Encode (dist: D/DA/DANKOGAI/Encode-3.08.tar.gz)
    lib (dist: S/SM/SMUELLER/lib-0.63.tar.gz)
    version (dist: L/LE/LEONT/version-0.9928.tar.gz)
      base (dist: R/RJ/RJBS/base-2.23.tar.gz)
  Struct::Conditional (dist: L/LN/LNATION/Struct-Conditional-1.00.tar.gz)
    Clone (dist: A/AT/ATOOMIC/Clone-0.45.tar.gz)
      B::COW (dist: A/AT/ATOOMIC/B-COW-0.004.tar.gz)
Enter fullscreen mode Exit fullscreen mode

You can also see the JSON::Conditional deps (here for perl 5.26.1) on deps.cpantester.org:
CPANDeps CPANTesters

Or a nice view (configurable) on cpandeps.grinnz.com:
CPANDeps grinnz

None of these 2 pages give the exact same result than the command line, I haven't checked why, we could discuss in comments (maybe something with dynamic/static).

List system requirements

Several modules require libraries or development kit that CPAN can't satisfy (even if Alien modules can often fill this gap). Having a CPAN module installation failing because a dependency is missing is "normal". It is like when you compile something, it fails while reporting a missing header because you need to install it before. To help you and automatic tests, Slaven Rezić gathered system dependencies for us in the tool cpan-sysdeps

$ cpan-sysdeps --cpanmod Imager
libfreetype6-dev
libgif-dev
libpng-dev
libjpeg-dev
libtiff5-dev
Enter fullscreen mode Exit fullscreen mode

I was mad when I discovered this module, come on MetaCPAN and hit the "++" button!

++

Conclusion

If you have more to add to this list, please share! πŸ˜„

Discussion (5)

Collapse
mjgardner profile image
Mark Gardner • Edited

I use cpan-outdated along with cpm to update my modules in parallel, saving time.

% cpan-outdated -p | xargs cpm install --global --verbose --test
92935 DONE resolve   (0.332sec) List::Util -> Scalar-List-Utils-1.56 (from MetaDB)
92936 DONE resolve   (0.354sec) Moose -> Moose-2.2015 (from MetaDB)
92935 DONE fetch     (0.448sec) Scalar-List-Utils-1.56
92935 DONE configure (0.597sec) Scalar-List-Utils-1.56
92936 DONE fetch     (1.055sec) Moose-2.2015
92936 DONE configure (8.329sec) Moose-2.2015
92935 DONE install   (8.858sec) Scalar-List-Utils-1.56
92935 DONE install   (129.369sec) Moose-2.2015
2 distributions installed.
Enter fullscreen mode Exit fullscreen mode
Collapse
grinnz profile image
Dan Book

Didn't know about cpan-listchanges and cpan-sysdeps, very cool :)

The differences in CPAN deps reported is likely because of whether core modules are excluded for a particular Perl version, and whether recommends/suggests are included.

Collapse
drhyde profile image
David Cantrell

FYI the CPANdeps website will go away soon.

Collapse
thibaultduponchelle profile image
Tib Author • Edited

Thank you. I see it's back to life now πŸ˜ƒ πŸ‘

Collapse
raigaurav profile image
Gaurav Rai

Nice. I was unaware of almost all of them (except cpandeps.grinnz.com)