Ever wonder how many CPAN distributions use Module::Build, or Module::Install? Or how common the different ways Changes, ChangeLog, Changelog, etc. show up in a distribution? Or how many distributions use a particular expression in code?

I wrote App::CPAN::Mini::Visit and the visitcpan tool to make answering such questions a lot easier.

It provides a command line tool that unpacks each distribution tarball in a CPAN::Mini repository, visits the resulting directory, and executes another program. For example, listing all distributions that contain Build.PL:

$ visitcpan --append=dist -- perl -E 'say shift if -f "Build.PL"' AASSAD/Catalyst-Helper-Controller-Scaffold-HTML-Template-0.03.tar.gz ABERGMAN/Alien-0.91.tar.gz ABERGMAN/File-Find-Random-0.5.tar.gz ABERGMAN/SVL-0.29.tar.gz ...

Clearly, if I were running frequent analyses, I might just use CPAN::Mini::Extract and keep all the tarballs extracted, but since I only occasionally have questions like this, I'm willing to make the space/time tradeoff.

Oh, and to answer that first question, here's how many distributions use each style of installer:

$ visitcpan -- perl -E 'if (-f "inc/Module/Install.pm") { say "MI" } e +lsif (-f "Build.PL") { say "MB" } elsif (-f "Makefile.PL") { say "EUM +M" }' | perl -E 'while (<>) { chomp; $cnt{$_}++ } say "$_: $cnt{$_}" +for keys %cnt' MI: 2306 MB: 2675 EUMM: 11781

Looks like Module::Install has almost caught up to Module::Build. Impressive!

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


In reply to How to look inside every CPAN distribution by xdg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.