PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mod_perl question
by davido (Cardinal) on Apr 11, 2011 at 22:36 UTC | |
|
Re: mod_perl question
by grantm (Parson) on Apr 13, 2011 at 09:18 UTC | |
|
Re: mod_perl question
by locked_user sundialsvc4 (Abbot) on Apr 12, 2011 at 00:21 UTC | |
|
Re: mod_perl question
by Anonymous Monk on Apr 12, 2011 at 10:59 UTC | |
|
Re: mod_perl question
by scorpio17 (Canon) on Apr 12, 2011 at 15:44 UTC |