![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Random Image in HTMLby cei (Monk) |
on Apr 24, 2000 at 23:19 UTC ( #8772=snippet: print w/replies, xml ) | Need Help?? |
#!/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]; }
|
|