#!/usr/bin/perl
use strict;
use CGI qw( param header );
sub image { # Give it a word, it gives you an image!
use LWP::UserAgent;
my $word = shift;
my $ua = LWP::UserAgent->new;
$ua->agent('Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101');
my $request = HTTP::Request->new('GET','http://images.google.com/images?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&q=' . $word);
my $response = $ua->request($request);
my $data = $response->content;
my @urls = ($data =~ m/\?imgurl=(.*?)&/g);
my $url = $urls[rand @urls];
$url = 'http://' . $url;
}
print header;
my $word = param("word");
$word =~ s/<(.*?)>//g;
$word =~ s/\+//g;
!($word =~ / /) || die "ONE WORD ONLY";
if ($word) {
print <
The Stream
The Stream
HEAD
my $ip = $ENV{"REMOTE_ADDR"};
open(RLASTIP,"lastip") || die "File Open Failed: $!";
my $lastip = ;
close(RLASTIP);
if (!($ip eq $lastip)) {
my $url = image($word);
open(WLIST,">>list");
print WLIST "$word $url\n";
close WLIST;
open(WLASTIP,">lastip") || die "File Open Failed: $!";
print WLASTIP "$ip";
close(WLASTIP);
} else {
print "";
}
open(RLIST,"list");
my @list = ;
close(RLIST);
foreach $_(@list) {
my ($link,$linkurl);
($link,$linkurl) = split(" ", $_);
print "$link";
}
print "
\n\n";
} else {
open(RLIST,"list") || die "File Open Failed: $!";;
my $lastline;
$lastline = $_ while ;
close(RLIST);
my ($lastword,$lasturl);
($lastword,$lasturl) = split(" ", $lastline);
print <
Stream of Consciousness
Stream of Consciousness
$lastword
Enter The First Word That Comes To Mind
MONKEY
}