package MyWebApp; use base 'CGI::Application'; use HTML::Template; # sub cgiapp_init { # # Called automatically right before setup(). # # Optional Initialization Hook # # Receives as its params, all the arg which were sent to new() # } sub setup { my $self = shift; $self->start_mode('mode1'); # $self->mode_param('rm'); $self->run-modes( 'mode1' => 'simplePage', 'mode2' => 'mode2', 'mode3' => 'mode3' ); # $self = param( # 'pageID' => 'default', # # baseFone, bgColor, DarkTone, Midtone, LightTone, TextColor # 'userDisplayPrefs' => ['5', 'white', '#00008B', '#00868B', '#EEE8AA', '#606060'] # ); } # sub cgiapp_prerun { # # }; sub get_common_stuff { my $this_mode = shift; my $calling_mode = shift; my @other_modes; @other_modes = (2, 3) if ($this_mode ==1); @other_modes = (1, 3) if ($this_mode ==2); @other_modes = (1, 2) if ($this_mode ==3); my $text_this = "This is run mode $this_mode"; my $text_called_from = "This mode was called from run mode $calling_mode"; my $href_goto_a = 'mywebapp.pl?rm=mode'.$other_modes[0].'&calling_mode='.$this_mode; my $text_goto_a = "To to run mode $other_modes[0]"; my $href_goto_b = 'mywebapp.pl?rm=mode'.$other_modes[1].'&calling_mode='.$this_mode; my $text_goto_b = "Go to run mode $other_modes[1]"; return ($text_this, $text_called_from, $href_goto_a, $text_goto_a, $href_goto_b, $text_goto_b); } # sub teardown { # Reserved for Future Use # my $self = shift; # # # Do things teardownish, like: # # Output to log file # # Close files or dBs # # Store info about the app to the server # } sub simplePage { my $this_mode = 1; my $self = shift; my $q = $self->query(); my $calling_mode = $q->param("calling_mode"); my $that_famous_string = 'Hello, world!'; my ($text_this, $text_called_from, $href_goto_a, $text_goto_a, $href_goto_b, $text_goto_b) = &get_common_stuff($this_mode, $calling_mode); my $output = ''; $output .= ''."\n"; $output .= "\n"; $output .= "
\n"; $output .= "$text_this
\n"; $output .= "$text_called_from
\n"; $output .= "$text_goto_a