I use shtml to generate random facts on my front page. To do this:
1. Create a cgi-bin directory
2. Create a facts.txt file in the cgi-bin directory and put facts in there: 1 fact per line
3. Create a file named facts.cgi in notepad
4. In facts.cgi, copy and paste the following code:
CODE
#!/usr/bin/perl -wT
use strict;
my $quote;
open(QUOTES, "facts.txt") or die "Oops! Can't find quote file: $!";
srand;
rand($.) < 1 && ($quote = $_) while <QUOTES>;
print "Content-type: text/html\n\n";
print $quote;
5. Where ever you want the random fact to appear, copy and paste the following code to your page:
CODE
<!--#include virtual="cgi-bin/facts.cgi"-->
Change "cgi-bin/facts.cgi" (w/o quotes) to where ever you stored your facts.cgi file
6. Upload your cgi-bin directory to your web space
7. Chmod facts.cgi to 755
8. Remember to name the web page file that will display the random fact as blah.shtml where blah is any name you wish. shtml extension should stay.
Good luck!
Btw, should I have made that a separate topic/tutorial? If you admins think so, can you please move it for me? Thanks!
Reply