I'm developing CGI's and modules for use under Apache with mod_perl. I would _like_ to have a module access the value of a variable in the callers package, namely $DEBUG.

$main::DEBUG works fine in the module when it is run from test.pl (make test). But when called from the CGI, it's undefined. OK, I looked at (caller)[0] (the callers package), which looks like (in my current project:
Apache::ROOTweb_2emgh_2eharvard_2eedu::dnacore::cgi_2dbin::synthesis::CE_QC</p>

So, since it will change, I thought I'd try to use the package name as a symbolic reference(slightly abridged):

my $pkg = (caller)[0]; no strict; warn("${$pkg::DEBUG} in $pkg"); # see what it gets

Which was still undefined. But if I use the package string literally:
warn("$Apache::ROOTweb_2emgh_2eharvard_2eedu::dnacore::cgi_2dbin::synthesis::CE_QC::DEBUG in $pkg");

I get the value expected. I've thrashed around and skimmed the docs for a while now, trying different ways of bracketing, attempting to typeglob, etc. Now it's way past time I ate and I'm frustrated. Please, if anyone can help solve this, I would, as always, be very appriciative!

TIA,
Sean

In reply to symbolic reference to variable in callers name space by spq

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.