Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have my setup code
sub setup { my $self = shift; $self->start_mode('Startup'); $self->tmpl_path('Templates/'); $self->run_modes( 'Startup' => 'Startup', 'Page' => 'Page' # more runmodes here ); };
Startup looks like:
sub Startup { # Startup function my $self = shift; my $q = $self->query(); my $template = $self->load_tmpl('index.tmpl'); $template->param( SITETITLE => "foobarbaz" ); # init more template paramaters and some session variables return $template->output(); # return template results }
My quesiton is this, is there a special runmode I can use to initialise appliaction(session) variables without having them in my default runmode so they don't get needlessly redeclared when someone goes back to the main screen?

Replies are listed 'Best First'.
Re: CGI::Application + run modes
by Anonymous Monk on Jul 19, 2011 at 14:04 UTC

    My quesiton is this, is there a special runmode I can use to initialise appliaction(session) variables

    Its called setup :) there is also cgiapp_prerun

      if I have warn "should run only once?"; in either setup or cgiapp_prerun I see it displayed in the logs each time I invoke my default runmode 'StartUp'.
        Yeah, and?