[thelist] random image w/ accompanying text?

Anthony Baratta Anthony at Baratta.com
Sun Jul 2 22:46:39 CDT 2000


Format each paragraph and picture the exact way you want it with HTML, and save that
in a file like option1.inc, option2.inc, option3.inc.

Create a flat file called option-db.txt and create a new line entry for each option
file like this


Create a header and footer file out of your current HTML page with the break point
being where you want the paragraph to be inserted. Call these header.inc and
footer.inc. If you have SSIs in your HTML, you can access this script as an SSI - or
just make sure the header and footer have ALL the content you want to display. This
script will not process SSIs embedded in the HTML. Make sure all your references to
links, images, et.al. are all Hard References, versus relative references.

Save the following script on the server, call it display.cgi and chmod to 755. Save
the Option#.inc files and the Header/Footer.inc files are in the same directory as
the script. (You can change this by referencing the option#.inc files with the 'full'
server (not web server) path to the files.) You
can call the display.cgi file as if it was an html file. This will execute the file
and it
should display a randomly selected option file.

Good Luck.

------ cut here ------

# change the above to match your installation
# of Perl, if necessary do a whereis perl to find it.

# Option Database file - ASCII text
$dbfile = "./option-db.txt";

# Header File
$header = "./header.inc";

# Footer File
$footer = "./footer.inc";

# Selecting Optional Include file
open (DBFILE,"<$dbfile");
   @OptionsDB = <DBFILE>;
$SelectedOption = $OptionsDB[int(rand($#OptionsDB+1))];

# Stitching together
$pageHTML = "Content-type: text/html\n\n";"

open (HEADER,"<$header");
   while (<HEADER>) {
      $pageHTML .= $_;

open (OPTION,"<$SelectedOption");
   while (<OPTION>) {
      $pageHTML .= $_;

open (FOOTER,"<$footer");
   while (<FOOTER>) {
      $pageHTML .= $_;

# Printing to Browser
print $pageHTML;

------- end cut here -----

Anthony Baratta
KeyBoard Jockeys
                    South Park Speaks Version 3 is here!!!
                              Powered by Tsunami

More information about the thelist mailing list