Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^6: Searching for Modules and Descriptions on CPAN Remotely

by ghenry (Vicar)
on Jan 23, 2006 at 16:38 UTC ( [id://524964]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Searching for Modules and Descriptions on CPAN Remotely
in thread Searching for Modules and Descriptions on CPAN Remotely

Yeah, I've now figured that out.

If you search for Catalyst::Plugin, you can see the results.

I just want the module name and the text directly below the link result.

Looks like I'll be turning to WWW::Mechanize after all :-(

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!
  • Comment on Re^6: Searching for Modules and Descriptions on CPAN Remotely

Replies are listed 'Best First'.
Re^7: Searching for Modules and Descriptions on CPAN Remotely
by randyk (Parson) on Jan 23, 2006 at 21:23 UTC

    At search.cpan.org, as well as within CPAN-Search-Lite, attempts are made to obtain module and package descriptions from the pod, if the CPAN indices don't have them. An alternative to downloading and extracting the pod, or using WWW::Mechanize, is to use the csl_soap script that comes with CPAN-Search-Lite to query, via a soap interface, the database that cpan.uwinnipeg.ca uses. If you set, within the script,

    my $soap_uri = 'http://theoryx5.uwinnipeg.ca/Apache/InfoServer'; my $soap_proxy = 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppminfo.cgi';
    then calling the script as:
    perl csl_soap --module Catalyst::Plugin::Geography
    will fetch the available information from the database, including the description.

    The mod_search function of PPM::Make::Util indicates how this soap service can accept an array reference of module names. Currently there isn't support for wild-card searches, but that could easily be added, if there was interest.

      Thanks randyk,

      This looks interesting, and I will have a play when I get a bit more time.

      I gave up on CPAN-Search-Lite as I just couldn't get Apache2-Request installed, as per the install requirement.

      Gavin.

      Walking the road to enlightenment... I found a penguin and a camel on the way.....
      Fancy a yourname@perl.me.uk? Just ask!!!
Re^7: Searching for Modules and Descriptions on CPAN Remotely
by adrianh (Chancellor) on Jan 23, 2006 at 16:42 UTC

    Try this:

    #! /usr/bin/perl use strict; use warnings; use CPANPLUS::Backend; # this will need to be more clever in the general case # (cross platform paths, odd locations, generated code, etc.) sub find_pod { my ( $dir, $module_name ) = @_; my $module_path = join '/', split /::/, $module_name; foreach my $extension ( qw( pod pm ) ) { my $file = "$dir/lib/$module_path.$extension"; return $file if -e $file; } return; } sub get_description_from_pod { my ( $filename, $module_name ) = @_; open my $fh, "<", $filename or die "open failed ($!)\n"; while ( my $line = <$fh> ) { chomp $line; return $1 if $line =~ m/^$module_name\s+-\s+(.*)$/s; } return; } sub description { my $module = shift; return $module->description if $module->description; $module->fetch or die CPANPLUS::Error->stack_as_string; my $dir = $module->extract or die CPANPLUS::Error->stack_as_string +; return 'unknown' unless my $pod_file = find_pod( $dir, $module->na +me ); return get_description_from_pod( $pod_file, $module->name ) or 'unknown'; } my $cb = CPANPLUS::Backend->new; my @modules = $cb->search( type => 'module', allow => [ qr/\ACatalyst: +:Plugin/ ] ); print $_->name, " : ", description( $_ ), "\n" foreach @modules

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://524964]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found