Takes a random file from a directory and spits it back out in an IMG tag.
#!/usr/bin/perl
######################################################################
+##########
# This script randomly selects a file from a directory of graphics and
+ returns
# that image to an HTML page. The proper method for calling this CGI w
+ould be
# from an HTML page, using <img src="randomimage.cgi">
#
# Copyright 1998 Click Active Media
# Code by Chuck Ivy (chuck@clickmedia.com)
######################################################################
+##########
$directoryname = "rndimg";
opendir(FILES,$directoryname);
@URL = readdir(FILES);
&chooseURL;
while (($random_URL eq ".") || ($random_URL eq "..")) {
&chooseURL;
}
print "Expires: Wednesday, 27-Dec-95 05:29:10 GMT", "\n";
print "Pragma: no-cache", "\n";
print "Location: $directoryname/$random_URL", "\n\n";
closedir(FILES);
sub chooseURL {
srand (time | $$);
$number_of_URL = $#URL;
$random = int (rand ($number_of_URL));
$random_URL = $URL[$random];
}