I am writing a random image generator and I have no idea what I am doing wrong. I run the file and it obviously outputs the picture to command prompt but when I try and access the file from <IMG SRC> it will not display the picture. I am quite new at perl itself so please bare with me.
Here is the script:
#! /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 <IMG>;
}
close IMG;
closedir DIR;
Thanks in advance for your guys' help.