Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How to look inside every CPAN distribution

by xdg (Monsignor)
on Dec 12, 2008 at 21:15 UTC ( #730049=perlmeditation: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re: How to look inside every CPAN distribution
by tsee (Curate) on Dec 13, 2008 at 13:26 UTC

    I've been waiting for such a tool for a long time now. It's been on my to-do list for an eternity and I never could convince myself to actually implement it.

    Thanks!

Re: How to look inside every CPAN distribution
by Anonymous Monk on Dec 13, 2008 at 12:24 UTC

      I needed output that would be valid input to CPAN.pm. I.e. "AUTHOR/DistName-0.00.tar.gz". Those links don't help without further processing.

      Also CPANTS shows distributions that list another as a prerequisite. That's not the same thing as distributions which have Build.PL.

      For example, most of my distributions use Build.PL but provide a traditional Makefile.PL as well for compatibility. (I use custom Build.PL to do helpful things when I'm authoring.)

      -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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://730049]
Approved by marto
Front-paged by almut
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-16 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (449 votes). Check out past polls.

    Notices?