Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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


    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://823079]
Approved by ww
Front-paged by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-02-22 03:56 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.