#!/usr/bin/perl
my $directory="images/front/src";
my @files=(glob("$directory/*.jpg"),glob("$directory/*.png"),glob("$directory/*.gif"));
my $file=$files[rand @files];
print "Status: 302 Found\n";
print "Location: $file\n";
print "\n";
Or, if you only have image files in that directory, you can change line 4 to:
my @files=glob("$directory/*");