I have just started getting into mod_perl (v2) and I need some help. I'm not getting the expected behaviour from the script that follows.

My module is loading and executing as I'd expect, however it's reloading upon each call from the browser. AFAIK, mod_perl is supposed to load the module once when Apache starts up, and then it should call the handler() once for each request from a browser.

This was the impression that I got from what I've been able to read. However I could be wrong. Am I?

If I'm right, please take a look at my code and let me know where I went wrong. Let me know why it reloads my script every time I call the directory in which it sits.

My .htaccess says:
SetHandler perl-script PerlResponseHandler Some::Module
My script is as follows. The warn() line is there so I can see from the logs (tail -f) when the script it reloaded:
package Some::Module; use strict; use warnings; use CGI; use Apache::RequestRec (); use Apache::RequestIO (); use Apache::Const -compile => qw(OK); # Log the loading of this handler warn("Reloading the handler.\n"); # Code snipped to create a DBI object # Code snipped to create a Cache::File object # Code snipped to create a HTML::Template object #--------------------------------------------------------------------- +- # Master apache query handler #--------------------------------------------------------------------- +- sub handler { my $r = shift; my $c = new CGI; $r->content_type('text/plain'); print $c->param('output'); return Apache::OK; }
P.S. Have I done anything that is against the mod_perl recommended way to do it?

Cheers!
Rick
If this is a root node: Before responding, please ensure your clue bit is set.
If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.

In reply to mod_perl reloading handler on each call by BigLug

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.