Sean M Burke has a nice little program in his book Perl & LWP which uses AltaVista to check the popularity of words, which I modified slightly to use Google instead. Here it is:
#!/usr/bin/perl
use warnings;
use strict;
# goolies: check popularity of words on Google. modified from:
# Example code from Chapter 2 of /Perl and LWP/ by Sean M. Burke
# http://www.oreilly.com/catalog/perllwp/
# sburke@cpan.org
use LWP;
use URI::Escape;
die "Usage: goolies word1 word2\n" unless @ARGV;
foreach my $word (@ARGV) {
next unless length $word;
my $url = 'http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=
+'
. uri_escape($word) . '&btnG=Google+Search';
my ($content, $status, $is_success) = do_GET($url);
if (!$is_success) {
print "Sorry, failed: $status\n";
} elsif ($content =~ m#of about <b>(\d+,?\d*,?\d*)</b>#) {
print "$word: $1 matches\n";
} else {
print "$word: couldn't extract count due to some weird shit at
+ $url\n";
}
sleep 2; # be nice to Google's servers!!!
}
##### subs #####
sub do_GET {
my $browser = LWP::UserAgent->new();
$browser->agent('Mozilla/4.76 [en] (Win98; U)'); # tricked you!
my $response = $browser->get(@_);
return ($response->content, $response->status_line, $response->is_
+success, $response) if wantarray;
return unless $response->is_success;
return $response->content;
}