#!/usr/bin/perl

use HTTP::Lite;

$http = new HTTP::Lite;
print "doing google search for ".$ARGV[0]."\n";

#plus signs are spaces - we actually want plus signs
$ARGV[0] =~ s/\+/%2B/g;
$ARGV[0] =~ s/ /\+/g;

$req = $http->request("http://www.google.com/search?q=".$ARGV[0]);
#print "http://www.google.com/search?q=".$ARGV[0]."\n";
$body = $http->body();
#print $body."\n";

#regex time
$body =~ /<h2 class=r style="font-size:138%"><b>([^<]*)<\/b>/;

print "calculator result: ".$1."\n";

