#!/usr/local/bin/perl
#------------------------------------------------------------------------------#
#  PROGRAM:  quote.cgi (a daily quote server)
#  NOTE:     this CGI program should be called from a server-side 
#               include (SSI) statement.
#------------------------------------------------------------------------------#
#  Copyright 1998 DevDaily Interactive, Inc.  All Rights Reserved.
#------------------------------------------------------------------------------#

#  This is the name of the quote-server database file

   $quoteFile = "quotes.db";


#  first, get the day of the month

   $dayOfMonth = (localtime(time))[3];


#  next, open the quote database file.

   open(QDB,"$quoteFile") || die 
      "Content-type: text/html\n\n<P>Error opening quote database file.\n";


#  Next, read through the database until we find a line that matches 
#  the $dayOfMonth.  (Note: no error-checking is done here currently.)

   until ( $currentLine == $dayOfMonth ) {
      $currentLine = <QDB>;
   }


#  *Assuming* that the $dayOfMonth was found, we should now be positioned at
#  the "<BLOCKQUOTE>" line.

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

#  Next, print each line from the database until the closing 
#  </BLOCKQUOTE> tag is found.

   until ($currentLine =~ /<\/BLOCKQUOTE>/)  {
      $currentLine = <QDB>;
      print $currentLine;
   }

   close(QDB);


#  All done!

   exit;
