#! /usr/bin/perl

use CGI qw(param);

my $QUERY = param("query");

print ("Content-type: text/html\n\n");

print qq(
<HTML>
        <blockquote> <blockquote>
        <font face="Arial,Helvetica" color="#999900">
<form method="GET" ACTION="">
<INPUT type="text" wrap="virtual" rows="10" cols="60" name="query" value="$QUERY"></form>
<BR>
<PRE>

);

@QUERIES = split(/\s+/, $QUERY);
foreach $LINE (@QUERIES)
{
	chomp($LINE);
	@GOOGLE_DATA = `/usr/bin/lynx -term=vt102 -nolist -dump \"http://www.google.com/search?q=%22${LINE}\"`;
	foreach $GOOG_LINE (@GOOGLE_DATA)
	{
		chomp($GOOG_LINE);
		if ($GOOG_LINE =~ /Results.*about/)
		{
			@NUMBER_LINE_DATA = split(/\s+/, $GOOG_LINE);
			$THE_NUMBER = $NUMBER_LINE_DATA[12];
			$THE_NUMBER =~ s/\.//g;
			print ("$LINE       \t$THE_NUMBER\n");
		}
	}

}

print qq(
</PRE>
</HTML>
);
