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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.