use CGI; my $img = CGI->new->param('name'); my ($type) = (lc($img) =~ m/([^\.]+)$/s); my %switch = qw/jpg jpeg tif tiff/; $type = $switch{$type} if exists $switch{$type}; print "Content-type: image/$type\n\n"; open(IMG,"; close(IMG);