Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

searching cpan.org from the commandline

Tags:

perl

cpan

I'm wondering if there's a feature to CPAN that allows the user to search all the modules available at CPAN.org.

I could probably just write something that sends the get request and spits back the answers...just wondering if there is already a built in utility...it would be really great.

I like how in debian or ubuntu linux, there is this thing "apt-cache search", or "aptitude search", that shows you which packages are already installed, and which packages are potentially available for you system. It would be a really great thing if there was something like this for perl modules/CPAN.

like image 326
pepper Avatar asked Mar 07 '13 21:03

pepper


2 Answers

You can run Perl's CPAN module interactively:

# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]> i /JSON::XS/
Reading '/home/alt/.cpan/Metadata'
  Database was generated on Wed, 06 Mar 2013 23:07:32 GMT
Module  < Catalyst::Action::Deserialize::JSON::XS (BOBTFISH/Catalyst-Action-REST-1.06.tar.gz)
Module  < Catalyst::Action::Serialize::JSON::XS (BOBTFISH/Catalyst-Action-REST-1.06.tar.gz)
Module  < JSON::XS               (MLEHMANN/JSON-XS-2.33.tar.gz)
Module  < JSON::XS::Boolean      (MLEHMANN/JSON-XS-2.33.tar.gz)
Module  < JSON::XS::VersionOneAndTwo (LBROCARD/JSON-XS-VersionOneAndTwo-0.31.tar.gz)
Module  < Mojo::JSON::XS         (YSYROTA/Mojo-JSON-Any-0.990104.tar.gz)
Module  < Mojo::JSON::XS::_Bool  (VTI/Mojo-JSON-Any-0.990103.tar.gz)
Module  < Sledge::Plugin::JSON::XS (TOKUHIROM/Sledge-Plugin-JSON-XS-0.05.tar.gz)
8 items found
like image 191
PSIAlt Avatar answered Sep 25 '22 18:09

PSIAlt


There's also the cpan script that may be in your path. So, instead of typing

perl -MCPAN -eshell

you can just type

cpan

And that drops you into the CPAN shell.

Then, from the CPAN> prompt, you type i /ModuleName/ to search for modules. What would be really nice is to have the cpan script handle the i /ModuleName/ but for now, only -L is available which lists a particular module author's modules.

like image 32
mrk Avatar answered Sep 25 '22 18:09

mrk