# random_image.pl A perl script for enlivening web sites. Mark Blaxter 29/06/2006 This CGI script displays a different picture on a web page every time it is called (for instance when the web page is revisited, or reloaded). It can be placed into any web page as long as - the web server has a cgi-bin directory set up - and the web server is setup so as to allow cgi scripts # to use, 1 Decide where you are going to keep the text files that go with your random images. Change the line in the script that tells the process where to look for files to process to fit this (the $datapath directory). You can have multiple instances of the script with different names pointing to different directories. 2 Place the script in cgi-bin (or wherever your server is set up to run cgi scripts from), and change its permissions to 755. (e.g. chmod 755 random_image.pl) 3 Place the following text in the place in the html page you wish to have the images displayed: Note that if you change the name of the script, you will have to change the "random_image.pl" part, and if your server does not use "/cgi-bin/" for cgi-scripts you will have to change that too. For many web servers you will have to change the name of the html page to .shtml, where the "s" tells the server that there is something to compute in the page. 4 For each image create a text file ("XYZ.txt") containing the actual html code to call the picture and the text describing the picture, and save it to the directory $datapath. For instance, for XYZ.jpg being served from directory randomimages, the XYZ.txt file might read: an XYZ imageA picture of an XYZ, which is more interesting than ABC
Obviously, you don't have to collect the photos in the same directory as the text files.