Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

A command-line utility to list CPAN modules/dists?

by sedusedan (Monk)
on Jul 21, 2012 at 02:58 UTC ( #982944=perlquestion: print w/replies, xml ) Need Help??

sedusedan has asked for the wisdom of the Perl Monks concerning the following question:

Is there a simple command-line utility to what modules a CPAN distribution contains, and vice versa in what CPAN distribution(s?) a module is contained? Something in the spirit of 'corelist' (Module::CoreList) or 'module-version' (App::module::version)

Imagined sample input/output:

$ cpandist-contents Foo-Bar

$ cpanmod-find Foo::Bar::Sub3
  • Comment on A command-line utility to list CPAN modules/dists?

Replies are listed 'Best First'.
Re: A command-line utility to list CPAN modules/dists?
by Khen1950fx (Canon) on Jul 21, 2012 at 03:17 UTC
Re: A command-line utility to list CPAN modules/dists?
by Anonymous Monk on Jul 21, 2012 at 06:28 UTC
Re: A command-line utility to list CPAN modules/dists?
by tobyink (Canon) on Jul 21, 2012 at 09:33 UTC

    The MetaCPAN API should make something like that pretty easy.

    Here's a list of modules from the distribution name...

    perl -MLWP::Simple -MJSON -MURI::Escape -E'my $data = from_json get sprintf ",path,module&size=4999", uri_escape shift; say for map { sprintf "%s %s", $_->{name}, $_->{version} } map { @{$_->{fields}{module}} } @{$data->{hits}{hits}}' Moose

    ... I leave the reverse as an exercise for the reader.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Thanks! Scriptified:

Re: A command-line utility to list CPAN modules/dists?
by tobyink (Canon) on Jul 21, 2012 at 09:44 UTC

    Oh yes, and how could I forget. For module-to-distribution, how about P5U?

    $ p5u version --local --cpan List::MoreUtils List::MoreUtils /home/tai/perl5/perlbrew/perls/thr-5.16.0/lib/site_perl/5.16.0/i68 +6-linux-thread-multi/List/ 0.33 cpan:VPARSEVAL/List-MoreUtils-0.10.tar.gz#lib/List/ 0 +.10 (2005-04-01T17:59:44.000Z) cpan:VPARSEVAL/List-MoreUtils-0.11.tar.gz#lib/List/ 0 +.11 (2005-09-27T06:19:03.000Z) cpan:VPARSEVAL/List-MoreUtils-0.12.tar.gz#lib/List/ 0 +.12 (2005-09-28T06:16:49.000Z) cpan:VPARSEVAL/List-MoreUtils-0.13.tar.gz#lib/List/ 0 +.13 (2005-11-09T15:47:32.000Z) cpan:VPARSEVAL/List-MoreUtils-0.14.tar.gz#lib/List/ 0 +.14 (2005-11-10T12:20:58.000Z) cpan:VPARSEVAL/List-MoreUtils-0.15.tar.gz#lib/List/ 0 +.15 (2005-11-11T08:34:08.000Z) cpan:VPARSEVAL/List-MoreUtils-0.16.tar.gz#lib/List/ 0 +.16 (2005-11-14T09:05:01.000Z) cpan:VPARSEVAL/List-MoreUtils-0.17.tar.gz#lib/List/ 0 +.17 (2005-12-07T10:01:10.000Z) cpan:VPARSEVAL/List-MoreUtils-0.18.tar.gz#lib/List/ 0 +.18 (2006-02-25T08:44:56.000Z) cpan:VPARSEVAL/List-MoreUtils-0.19.tar.gz#lib/List/ 0 +.19 (2006-03-13T18:41:40.000Z) cpan:VPARSEVAL/List-MoreUtils-0.20.tar.gz#lib/List/ 0 +.20 (2006-06-10T17:51:04.000Z) cpan:VPARSEVAL/List-MoreUtils-0.21.tar.gz#lib/List/ 0 +.21 (2006-06-18T21:45:20.000Z) cpan:VPARSEVAL/List-MoreUtils-0.22.tar.gz#lib/List/ 0 +.22 (2006-07-02T15:22:41.000Z) cpan:ADAMK/List-MoreUtils-0.23_01.tar.gz#lib/List/ 0. +23_01 (2010-09-25T12:15:34.000Z) cpan:ADAMK/List-MoreUtils-0.24.tar.gz#lib/List/ 0.24 +(2010-11-22T01:19:56.000Z) cpan:VPARSEVAL/List-MoreUtils-0.25_01.tar.gz#lib/List/ +: 0.25_01 (2009-07-30T22:10:35.000Z) cpan:VPARSEVAL/List-MoreUtils-0.25_02.tar.gz#lib/List/ +: 0.25_02 (2009-08-01T10:51:57.000Z) cpan:ADAMK/List-MoreUtils-0.26.tar.gz#lib/List/ 0.26 +(2010-11-23T02:59:39.000Z) cpan:ADAMK/List-MoreUtils-0.27_01.tar.gz#lib/List/ 0. +27_01 (2010-12-01T10:39:41.000Z) cpan:ADAMK/List-MoreUtils-0.27_02.tar.gz#lib/List/ 0. +27_02 (2010-12-03T02:18:12.000Z) cpan:ADAMK/List-MoreUtils-0.27_03.tar.gz#lib/List/ 0. +27_03 (2010-12-06T01:33:39.000Z) cpan:ADAMK/List-MoreUtils-0.27_04.tar.gz#lib/List/ 0. +27_04 (2010-12-06T01:44:21.000Z) cpan:ADAMK/List-MoreUtils-0.28.tar.gz#lib/List/ 0.28 +(2010-12-07T00:20:43.000Z) cpan:ADAMK/List-MoreUtils-0.29.tar.gz#lib/List/ 0.29 +(2010-12-08T03:39:47.000Z) cpan:ADAMK/List-MoreUtils-0.30.tar.gz#lib/List/ 0.30 +(2010-12-16T03:03:27.000Z) cpan:ADAMK/List-MoreUtils-0.31_01.tar.gz#lib/List/ 0. +31_01 (2011-03-21T00:12:34.000Z) cpan:ADAMK/List-MoreUtils-0.31_02.tar.gz#lib/List/ 0. +31_02 (2011-03-21T00:44:38.000Z) cpan:ADAMK/List-MoreUtils-0.32.tar.gz#lib/List/ 0.32 +(2011-05-20T00:55:10.000Z)
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://982944]
Approved by kcott
Front-paged by cavac
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2023-12-05 05:55 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (25 votes). Check out past polls.