Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

cli to cpan search?

by leocharre (Priest)
on Feb 14, 2010 at 00:32 UTC ( [id://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. )

Replies are listed 'Best First'.
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.
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-03-19 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found