http://qs1969.pair.com?node_id=612553


in reply to CGI::Application with 'main' runmodes and 'sub' runmodes

Suggestions,

Example: instance script at /Sample/Launcher/Default.cgi

#!C:/Perl/bin/perl.exe use lib qw( /www/local/sw/admin/lib ); use Sample::Launcher; Sample::Launcher->new->run;

Now you know where every controller module is based upon the name of instance script. It provides consistency.

This would be your Main module.

package Sample::Main; use strict; use warnings; use base qw{CGI::Application}; use CGI::Application::Plugin::AutoRunmode; sub get_tmpl_path { my $self = shift; return '/Sample/'; } sub one :STARTRUNMODE { my $self = shift; my $tmpl = $self->load_tmpl( $self->get_tmpl_path() . 'One.tmpl' ); return $tmpl->output; } sub two :RUNMODE { my $self = shift; my $tmpl = $self->load_tmpl( $self->get_tmpl_path() . 'Two.tmpl' ); return $tmpl->output; } 1;

This sets you with some initial defaults. Now lets take advantage of this by inheriting its properties but and change the default path that is appropriate for that controller.

package Sample::Launcher; use strict; use warnings; use base 'Sample::Main'; sub get_tmpl_path { my $self = shift; return '/Sample/Launcher/'; }

Thats it! Your Sample::Launcher module has two run modes (One and Two), and can find the templates in '/Sample/Launcher/One.tmpl' and '/Sample/Launcher/Two.tmpl' . Notice, no redundancy! :)

Try that and see if it is not better for you.