home *** CD-ROM | disk | FTP | other *** search
- #!C:/perl/bin/perl
-
- # zippy.pl
- ######################################
- # Talk to Zippy
- #
- # A simple database of Zippy quotes
- # is displayed one line at a time
- # in response to user input
- #
- # Created: 1/31/2001
- # Author: Michael L. Curry
- # http://www.web-data.org
- # email: mlcurry@web-data.org
- ######################################
- # Copyright 2001, This script may be
- # distributed and modified as needed.
- # Please credit the author.
- ######################################
- # C O N F I G U R A T I O N
- # Make sure that these files are in the
- # same directory as this script
- require("cgi-lib.pl");
- $zip_pic = "../zippy.gif";
- $zip_txt = "zippy.txt";
- $applet = "zippy.pl";
-
- # add the path to this CGI, without the file name!
- $path = "http://localhost/htbin/";
-
- # that's it, your done!
- # Enjoy!
- ########################
- print "Content-type: text/html\n\n";
- &ReadParse(*form);
- $|=1; # turn on error messages
- $cgi = $path . $applet;
- $you = $form{'T1'};
-
- print <<HEADER;
- <html><head><title>Talk to Zippy</title>
- <script>
- function check()
- {
- if (document.forms[0].T1.value == '')
- {
- alert("Yow! Say something!");
- return false;
- }
- else return true;
- }
- </script></head><body>
-
- <p align="center"><img border="0" src=$zip_pic width="128" height="131"></p>
- <h2 align="center"><font face="Verdana">Hi, I'm Zippy, Talk to me!</font></h2>
- <form method="POST" action=$cgi onsubmit="return check()">
-
- <p><font face="Verdana"><input type="text" name="T1" size="42"><input type="submit" value="Yow!" name="B1"><input type="reset" value="Reset" name="B2"></font></p>
- </form>
- <p align="center"> </p>
- HEADER
- print "<p align='left'><font face='Verdana'><b>You Said: $you</b></font></p>";
- print "<p align='left'><font face='Verdana'><b>Zippy Says: ";
-
- open (DAT, "< $zip_txt") || die "Can't open $zip_txt:$!<br>";
- $knt = 0;
- while(<DAT>)
- {
- $line = $_;
- chop($line);
- push (@zippy,$line);
- $knt++;
- }
- srand;
- print "$zippy[rand $knt]";
- close(DAT);
- print <<FOOTER;
- </b></font></p>
- <hr>
- <p align="center"><font face="Verdana" size="1">Copyright ⌐2001 by <a href="mailto:mlcurry\@web-data.org">Michael
- Curry</a> Freely Use and Distribute, with this statement intact</font></p>
- </body>
- </html>
- FOOTER
-
-
-