#!/usr/bin/perl -wT use strict; use CGI ':all'; my $q = new CGI; my $imagedir = "/path/to/images"; my $file = $q->path_info(); $file =~ s!^.*/!!gi; print header("image/jpeg"), do { local *ARGV; @ARGV = "$imagedir/$file"; <> };