#! /usr/bin/perl -w # # Author: Joe Klemmer # Date: June 4, 1999 # License: Public Domain # # This script is supposed to get a random line from an input text file # and print that line to stdout. The purpose for this is to have a simple # banner rotating utility that can be used as an SSI. You need to create # a file that has the html code for the banners to be included. One line # per banner code. # # This program is a very crude hack but it works for the most part. # It was written by me in a few minutes just to see if I could remember # how to do it. It's not perfect and I hope to make it better as soon as # possible. In the mean time this code is released into the Public Domain. # There is no license or warranty or claim of merchantability. I will only # guarantee it will occupy space on your system, and very little at that. # # To use this utility place it in the same directory with the previously # mentioned banner file and run it as an SSI for your web server. # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Start Code # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# srand(); # seed the random function $n = 0; # set the offset variable open(IN,"@ARGV") or die "Can't open file: $!"; # open input file while(){ int(rand(++$n)) or $quote=$_; # read random line from file } close (IN); # close the file print $quote; # print the afor mentioned line exit; # done #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# End Code # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#