I am humbly aspiring to learn mod_perl by converting an existing, fairly complex, cgi application. Though I have been pretty successful getting most scripts to run under ModPerl::Registry, I'm getting remembered cgi.pm params. Which leads me to believe I have no clue on what gets shared.
I have one module called Security.pm with no global vars. I call a function which creates $q=CGI->new;, checks authorization and displays a login page with a param('login_name') if they are not logged in yet.
I have many different scripts with the following basic format:
sub main {
my $q = CGI->new;
my $func = $q->param('func');
if ($func eq 'somefunc') { &somefunc }
}
sub somefunc {
my $q = CGI->new;
}
My problem is that if I use param('login_name') in &somefunc it has a retained value from elsewhere, like the one entered in during login from the Security module. I tried '-override=>1' on that param and received an error that indicated I could not change the value of that param.
So are $q vars being somehow loaded up once in mod_perl and never cleared with each CGI->new?
I could certainly use some tips on understanding variable usage and sharing/not sharing under mod_perl. I am searching through 'practical mod_perl' as well.
I'd appreciate any pointers or direction on how to properly use modules like CGI.pm or how modules behave after they are loaded and compiled in mod_perl.
Your Humble Servant
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.