Hello all,
I am attempting to convert a program from a CGI application to a mod_perl application. To my understanding mod_perl will run CGI scripts however, running CGI only experience minor increase in performance.
My question is this: how do I write a multi-screen mod_perl program?
I haven't found a direct solution for the multi-screen mod_perl application; searching for a solution returns CGI solutions. Perhaps I am misunderstanding the use of handlers, essentially I don't want to have to create an entry in the httpd.conf file for every page on my website.
this is how I do it in my CGI script:
my $q = new CGI; my %States = ( 'Default' => \&index, 'Index' => \&index, 'Save' => \&save, 'Etc' => \&etc, ); # Query for the value of ".State" as passed by the POST # Method my $current_screen = $q->param(".State") || "Default"; die "No Screen for $current_screen" unless $States{$current_screen}; # iterate through values in %States for active page while (my ($screen_name, $function) = each %States){ $function->($screen_name eq $current_screen); } #generate pages based on sub called sub index { my $active = shift; return unless $active; do_stuff(); }
Then in my HTML template I use a submit button to change the state of the page, i.e.:
<input type="submit" name=".State" value="Index" /> <input type="submit" name=".State" value="Save" /> <input type="submit" name=".State" value="Etc" />
perhaps I am misunderstanding the use of handlers, or the configuration of mod_perl. What I would like to avoid is an entry in httpd.conf for every page (and this is where I think I might be misunderstanding something.).
I am under the impression that to create multiple pages I'll do the following:
PerlRequire /var/www/Index.pm <Location / > SetHandler perl-script PerlHandler Index PerlSendHeader On Allow from all </Location> PerlRequire /var/www/Save.pm <Location /Save> SetHandler perl-script PerlHandler save PerlSendHeader On Allow from all </Location> PerlRequire /var/www/Etc.pm <Location /Etc> SetHandler perl-script PerlHandler Etc PerlSendHeader On Allow from all </Location>
If the above would be used for a website with multiple pages, but then how would I create a multi-screen application?
Am I way off? I think I might be close but I'm not sure.
Thanks for the help
In reply to mod_perl question by PyrexKidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |