#!/usr/local/bin/perl $| = 1; $_ = $ENV{'QUERY_STRING'}; #print 'foo $_ \n'; /Subject=(.*)&This=(.*)&That=(.*)/; $Subject = $1; $This = $2; $That = $3; if (! open (WEBPIPE1, "/usr/bin/lynx -dump http://www.altavista.com/cgi-bin/query?pg=aq\\\&text=yes\\\&kl=XX\\\&r=\\\&act=search\\\&q=%22$Subject+is%22+NEAR+$This\\\&d0=\\\&d1=\\\&fmt=n |" )) { die "Can't run webcopy (1)! $!\n"; } while() { chop; if(/about (.*) Web/) { $thisresult = $1; } } if (! open (WEBPIPE2, "/usr/bin/lynx -dump http://www.altavista.com/cgi-bin/query?pg=aq\\\&text=yes\\\&kl=XX\\\&r=\\\&act=search\\\&q=%22$Subject+is%22+NEAR+$That\\\&d0=\\\&d1=\\\&fmt=n |" )) { die "Can't run webcopy (2)! $!\n"; } while() { chop; if(/about (.*) Web/) { $thatresult = $1; } } print <Results

Results

END_MARKER

$Subject =~ s/\+/ /g;
$This =~ s/\+/ /g;
$That =~ s/\+/ /g;

if($thisresult > $thatresult) { print "A $Subject is more likely to be a $This \n"; }
elsif($thatresult > $thisresult) { print "A $Subject is more likely to be a $That \n"; }
else { print "I'm not sure which it's more likely to be"; }

#print "$thisresult , $thatresult \n";
print "
\n";