use SOAP::Lite;

my $key='UIXCdpdQFHKrtjcj/ryLGVMEX/NMgK+p';
my $query="uct computer science";
my $googleSearch = SOAP::Lite -> service("file:./GoogleSearch.wsdl")
                              -> proxy ('http://api.google.com/search/beta2',
                                        proxy => ['http' => 'http://cache.uct.ac.za:8080']);
my $result;
my $max_retries = 0;
my $retry_count = 0;
while (!$results->{resultElements} && $retry_count <= $max_retries)
{
   eval {
      $result = $googleSearch -> doGoogleSearch(
        $key, $query, 0, 10, "false", "", "false", "", "latin1", "latin1");
   };
   $retry_count++;
}

print "About $result->{'estimatedTotalResultsCount'} results.\n";
foreach my $aresult (@{$result->{'resultElements'}})
{
   print (sprintf ("%s\n   URL: %s\n", $aresult->{'title'}, $aresult->{'URL'}));
}
