package Handler; use strict; use warnings; my %handlers = ( '/' => 'Handler::Index', '/logout' => 'Handler::Logout', '/details' => 'Handler::Details', ); sub handler ($$) { my $self = shift; my $r = shift; $self = $self->new( r => $r ) unless ref $self; my $uri = $r->uri; # User auth etc. can happen here. if ( my $handler = $handlers{ $uri } ) { eval "require $handler" || die "Error with $handler"; return $handler->handler( $r ); } # If not on list then it was not found. return NOT_FOUND; } ######### # httpd.conf SetHandler perl-script PerlHandler Handler