#!/usr/local/bin/perl use MyApp; my $webapp = MyApp->new(); $webapp->start_mode('show_survey'); $webapp->run; #### package MyAuth; use base 'CGI::Application'; use strict; use warnings; sub cgiapp_init { my $self = shift; # set the name of the run mode CGI param $self->mode_param('rm'); # shared run modes $self->run_modes([ 'login', 'AUTOLOAD' ]); } sub cgiapp_prerun { my $self = shift; my $runmode = shift; my $authorized = $self->param('authorized'); unless ($authorized) { $self->prerun_mode( 'login' ); } } sub login { my $self = shift; my ($error) = @_; my $output = "

sub MyAuth::login entered

"; my %params; $params{'ERROR'} = $error if defined($error); # load/process login template # for test purposes assume user authenticates successfully $self->param('authorized', 1); $output .= $self->dump_html(); return $output; } sub AUTOLOAD { my $self = shift; my $output = "

sub MyAuth::AUTOLOAD entered

"; $output .= "

### ERROR - Invalid runmode '" . $self->mode_param('rm') . "'

"; return $output; } 1; ##
## package MyApp; use base 'MyAuth'; use strict; use warnings; sub setup { my $self = shift; my $output = "

sub MyApp::setup entered

"; $self->start_mode('show_survey'); $self->run_modes([ 'show_survey', 'save_survey' ]); return $output; } sub show_survey { my $self = shift; my $output = "

sub MyApp::show_survey entered

"; return $output; } sub save_survey { my $self = shift; my $output = "

sub MyApp::save_survey entered

"; return $output; } 1;