#!/usr/bin/perl -wT
use strict;
# Call in img tag - e.g.:
my @files = glob("./jpegs/*.jpg");
print "Location: $files[int(rand @files)]\n\n";
####
#!/usr/bin/perl -wT
use strict;
use URI;
my @files = glob("./images/*");
my $file = URI->new_abs($files[int(rand @files)], "http://bugzilla");
print "Status: 307 Temporary redirect\n";
print "Location: $file\n\n";
####
#!/usr/bin/perl -wT
use strict;
# types where extension <> content-type
my %types = qw(jpg jpeg tif tiff);
# get an array of image-files
my @images = glob("./images/*");
die "No images found\n" unless scalar @images;
# choose an image and and prepare content type extension
my $image = $images[int(rand @images)];
die "No extension for $image\n" unless $image =~ /\.(.+)$/;
my $ctype = $1;
$ctype = $types{$ctype} if exists $types{$ctype};
# read and print image
open(IMG, $image)||die "Cannot open $image:$!\n";
print "Content-type: image/$ctype\n\n";
binmode (IMG);
binmode (STDOUT);
print while(
);
close IMG;