Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

cli to cpan search?

by leocharre (Priest)
on Feb 14, 2010 at 00:32 UTC ( #823079=perlquestion: print w/ replies, xml ) Need Help??
leocharre has asked for the wisdom of the Perl Monks concerning the following question:

Is there a cli to mimic http://search.cpan.org ? I'm imagining something like..
Search insensitive, print the name and abstract for each;
   cpansearch -a -n -i cgi

Search case sensitive, print the name and readme to each result;
   cpansearch -n -r CGI
I'm tempted to write this out, but it might be silly- especially if there's something out there. ( I can see some examples in CPAN::Search::Lite. And WWW::CPAN looks quite relevant here. )

Comment on cli to cpan search?
Re: cli to cpan search?
by Anonymous Monk on Feb 14, 2010 at 00:46 UTC
    nope, does not exist
      "Does not exist" is extreme.. Some stuff comes close, WWW::CPAN's cpanq is pretty beautiful, the output is not refined, but functionality is nice.
Re: cli to cpan search?
by CountZero (Bishop) on Feb 14, 2010 at 07:57 UTC
    the cpan shell can do it, so it should not be too difficult to lift that part out of the code and incorporate it into a cpansearch script.

    Actually, it can be as easy as:

    package main; use strict; use warnings; use Modern::Perl; use CPAN; CPAN::HandleConfig->load; CPAN::Shell::setup_output; CPAN::Index->reload; my $search = shift @ARGV; my @modules = CPAN::Shell->expand("Module","/$search/"); say CPAN::Module::as_glimpse($_) for @modules; 1;
    Add some option handling and argument checking and you are done!

    Update: added an example script.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: cli to cpan search?
by bduggan (Pilgrim) on Feb 14, 2010 at 16:57 UTC
    There's also surfraw which includes "scpan" which will pull up results in a text-based browser.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://823079]
Approved by ww
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-07-23 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (135 votes), past polls