#!/usr/bin/perl -w # foo.pm , to be executed by Apache package foo; use strict; use base 'CGI::Application'; use CGI::Carp; sub handler { warn "## handler"; my $request = shift; my $app = foo->new(); $app->run(); exit; } sub setup { warn "## setup"; my $self = shift; $self->run_modes( start=>'start' ); } sub start { warn "## start"; my $self = shift; open ( FH , '/path/to/some/image' ) or confess $!; $self->header_props( -type=>'your/mimetype' ); return join '' , ; } 1;