#!/usr/bin/perl

$SOURCE = "/www/celldynamics/images/splash/";

# Read in a list of all images

@images = ();

open(DIR,"ls -1 $SOURCE |");
while (<DIR>) {
  chop;
  push(@images,$_);
}
close(DIR);

# Generate a random number

srand(time ^ $$ ^ unpack "%32L*", 'ps axw | gzip');
$i = int(rand($#images+1));

$file = $images[$i];

$img = "";

open(IMG,$SOURCE.$file);
while (<IMG>) {
  $img .= $_;
}
close(IMG);

print <<EOF;
Content-Type: image/jpeg

$img
EOF


