#! /usr/bin/perl $urldir = "http://jason.yellowsnow.net/images/"; $dir = "."; opendir(DIR,$dir) || die "Unable to open $urldir: $!"; @files = grep { /\.(?:jpg)$/i } readdir DIR; srand (time ^ $$); $file = rand(@files); open(IMG,$files[$file]) or die "Unable to open $files[$file]: $!"; print "Content-type: image/jpg\n\n"; { print ; } close IMG; closedir DIR;