;
close(FILE);
# Join these lines from the file into one large string.
$phrases = join('',@FILE);
# Now split the large string according to the $delimiter.
@phrases = split(/$delimiter/,$phrases);
# Invoke srand; with a seed of the time and pid. If you are on a machine
# which doesn't put the pid into $$ (ie. Macintosh, Win NT, etc...), change
# this line to: srand(time ^ 22/7);
srand(time ^ $$);
# Now pluck our random phrase out of the @phrases array! But wait! This
# only returns a number.
$phrase = rand(@phrases);
# Print out the Content-type header, so the browser knows what's going on.
print "Content-type: text/html\n\n";
# Change this number into the text we want to return and print it!
print $phrases[$phrase];
# All Done!
exit;
# Was there an error? If so, let's report that sucker so it can get fixed!
sub error {
($error,$file) = @_;
print <<"END_ERROR";
Content-type: text/html
ERROR: Random File Unopenable
ERROR: Random File Unopenable
The random file, as specified in the \$random_file perl variable was
unopenable.
END_ERROR
if (-e $random_file) {
print "The file was found on your system, so make sure that it is\n";
print "readable by the web server. This means you will need to\n";
print "execute the following command:
\n";
print " chmod 744 $random_file\n";
print "
\n";
}
else {
print "The file was not found on your file system. This means that\n";
print "it has either not been created or the path you have specified\n";
print "in \$trrandom_file is incorrect.\n";
}
exit;
}