Alex on Camel, Egypt
Butchers in Moshi, Tanzania
Remarkable Rocks, Kangaroo Island
Summer Palace, China
Dorota on Brighton Beach

HTML Random Image Script

Well I wanted to create a random image display for one of my sites, but all I could find were JavaScript random image scripts, the problem with the ones I found were that the script had to contain all the list of images, it had to be in the body tag too so couldnt intergrate the Java Script and the image list into an external file.

I had a good look for PHP random image scripts, but nothing as simple as I wanted, so I decided now was the time to brush up on my perl and create my own.

#! /usr/local/bin/perl -w
$basedir = "http://www.code-d.com/papa-smurf/random/";
@files = ("strip01.jpg", "strip02.jpg", "strip03.jpg",);
$num = rand(@files);
print "Location: $basedir$files[$num]nn";

All you need to do to use this script is obviously call it something like randomimage.pl, set your absolute path to Perl, and then stick it in your cgi-bin and set the permissions to 755.

All you need to do to use this script is obviously call it something like randomimage.pl, set your absolute path to Perl, and then stick it in your cgi-bin and set the permissions to 755. To call a random image you just reference it like a normal image.

All you need to do to use this script is obviously call it something like randomimage.pl, set your absolute path to Perl, and then stick it in your cgi-bin and set the permissions to 755. To call a random image you just reference the script like you would for a normal image. If you want to see an example please check out my papa smurf site.