I assume you're developing under the strict pragma, correct?

It sounds like you're creating your CGI object as a lexical variable (like my $q=new CGI;) and expecting it to be global throughout all your subroutines. For some crazy reason, this isn't how variable scoping behaves under mod_perl, specifically the Apache::Registry handler. When the above happens, you can't predict what value your CGI object will have in a nested subroutine. Sometimes nothing, sometimes a previous value, etc. It's very bizarre, 'cuz your script will run fine under regular CGI.

See This node for a long discussion of this. You have a few options. Probably the easiest one is to declare the CGI object as global with a global variable at the top of your script, (ala use vars qw/$q $dbh/;)

perl.apache.org has fabulous documentation. Go here for all you need to know about variable scoping and mod_perl

Update: After re-reading your post, this might be more useful to you. It discusses sharing global variables between modules.


In reply to Re: CGI.pm not returning POSTed param w/mod_perl by Hero Zzyzzx
in thread CGI.pm not returning POSTed param w/mod_perl by voyager

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.