Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Created March 11, 2010 21:36
Show Gist options
  • Save yusukebe/329689 to your computer and use it in GitHub Desktop.
Save yusukebe/329689 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use URI::Escape qw( uri_escape );
use HTTP::Lite;
my $query = $ARGV[0] or die "query required\n";
my $url = 'http://search.cpan.org/search?m=all&q=' . uri_escape( $query );
my $http = HTTP::Lite->new;
$http->request( $url );
my @paths = $http->body =~ m!<h2\s+class=sr><a\shref=\"/~[^/]+/([a-zA-Z\-]+)-!mg;
for my $path ( @paths ){
$path =~ s/-/::/g;
print "$path\n";
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment