#!/usr/bin/perl use CGI qw(:standard); #Shakespear Lives! my $mode = param("mode"); if ($mode eq "palm") { print header; open(ONE,"/home/perlmonk/public_html/shakespear/one"); open(TWO,"/home/perlmonk/public_html/shakespear/two"); open(THREE,"/home/perlmonk/public_html/shakespear/three"); chomp(my @one = <ONE>); chomp(my @two = <TWO>); chomp(my @three = <THREE>); print "<HTML>\n"; print "Thou "; my $one = $one[rand @one]; print $one; print " "; my $two = $two[rand @two]; print $two; print " "; my $three = $three[rand @three]; print $three; print <<ENDFORM; <BR> <BR> <form action="http://www.takiweb.com/~perlmonk/shakespear/insult.cgi" +method="get" name="thingymabob"> <input type="hidden" name="mode" value="eval"> <input type="radio" name="rating" value="good" checked><b>Good</b><br> <input type="radio" name="rating" value="okay"><b>Okay</b><br> <input type="radio" name="rating" value="bad"><b>Bad</b><br> ENDFORM print "<input type=\"hidden\" name=\"one\" value=\"$one\">"; print "<input type=\"hidden\" name=\"two\" value=\"$two\">"; print "<input type=\"hidden\" name=\"three\" value=\"$three\">"; print <<FINALE; <input type="Submit" value="Rate it!" align="MIDDLE"> </form> FINALE print "</HTML>"; } if ($mode eq "gen") { open(ONE,"/home/perlmonk/public_html/shakespear/one"); open(TWO,"/home/perlmonk/public_html/shakespear/two"); open(THREE,"/home/perlmonk/public_html/shakespear/three"); chomp(my @one = <ONE>); chomp(my @two = <TWO>); chomp(my @three = <THREE>); print header; print <<EOT; <HTML> <BODY BGCOLOR=#000000 TEXT=#FF9900 LINK=#FF9900 VLINK=#FF9900> <CENTER><IMG SRC="shakespear.gif" ALT="Shakespear the talking head!">< +/CENTER> <CENTER><H3> EOT print "Thou "; my $one = $one[rand @one]; print $one; print " "; my $two = $two[rand @two]; print $two; print " "; my $three = $three[rand @three]; print $three; print "</H3>"; print "<BR>"; print "<BR>"; print "<H4>So was that,"; my $option; foreach $option("good","okay","bad") { print "<A HREF=\"insult.cgi?mode=eval&one=$one&two=$two&three=$three&r +ating=$option\">$option</A>"; print ","; } print "or are you paralyzed by its brilliance so much that you can't c +lick</H4>"; print <<END; </H4> </BODY> </HTML> END } if ($mode eq "eval") { my $one = param("one"); $one =~ s/\0//g; my $two = param("two"); $two =~ s/\0//g; my $three = param("three"); $three =~ s/\0//g; my $rating = param("rating"); if ($rating eq "good") { $/ = undef; open(ONE,"/home/perlmonk/public_html/shakespear/one"); my $checkone = <ONE>; if ($checkone =~ /$one\n/) { close(ONE); open(ONE,">>/home/perlmonk/public_html/shakespear/one"); print ONE "$one\n"; } open(TWO,"/home/perlmonk/public_html/shakespear/two"); my $checktwo = <TWO>; if ($checktwo =~ /$two\n/) { close(TWO); open(TWO,">>/home/perlmonk/public_html/shakespear/two"); print TWO "$two\n"; } open(THREE,"/home/perlmonk/public_html/shakespear/three"); my $checkthree = <THREE>; if ($checkthree =~ /$three\n/) { close(THREE); open(THREE,">>/home/perlmonk/public_html/shakespear/three"); print THREE "$three\n"; } } if ($rating eq "bad") { $/ = undef; open(ONE,"/home/perlmonk/public_html/shakespear/one"); open(TWO,"/home/perlmonk/public_html/shakespear/two"); open(THREE,"/home/perlmonk/public_html/shakespear/three"); my $listone = <ONE>; my $listtwo = <TWO>; my $listthree = <THREE>; close ONE; $listone =~ s/$one\n//; open (ONE,">/home/perlmonk/public_html/shakespear/one"); print ONE "$listone"; close TWO; $listtwo =~ s/$two\n//; open (TWO,">/home/perlmonk/public_html/shakespear/two"); print TWO "$listtwo"; close THREE; $listthree =~ s/$three\n//; open (THREE,">/home/perlmonk/public_html/shakespear/three"); print THREE "$listthree"; } print header; print"<HTML>\n<BODY BGCOLOR=#000000 TEXT=#FF9900 LINK=#FF9900 VLINK=#F +F9900>"; print "<H3>So that was $rating, eh?"; print '<A HREF="insult.cgi?mode=gen">rate another</A> </BODY></HTML>'; print "</H3>\n</BODY>\n</HTML>"; }
Edit Petruchio Tue Dec 25 17:05:08 UTC 2001 - Added READMORE tag, changed links to square-bracket notation.
In reply to Breeding Shakesperian Insults by beretboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |