In mod_perl, global variables keep their values over multiple requests, but that might not be a problem in configuration variables, because they usually do not change their values after initialisation.

I usually reference global 'constant' variables like:

# create global config package MyConfig; our $OPTION = 'option_value'; # and in some other file do: use MyConfig; print $MyConfig::OPTION;

I'm not 100% sure about this setup, though. On the one hand, accessing global variables with a package prefix makes for hard to spot spelling errors, on the other you can interpolate variables much more easily than constants created by use constant.

My 'reasonably paranoid' solution is to use warnings FATAL => 'all'; to intercept usage of undefined variables (and to force myself not to clog my error logs with useless warnings).

Local (not my) variables can be a problem in general and I would suggest not using them unless you really, really have to (like temporarily replacing a special global). I'm not aware of specific mod_perl problems with them, though. (But I might have missed something, as I said, I try to avoid using local variables at all).

HTH,
Joost


In reply to Re: Re: Re: Best perl environment for mySQL server? by Joost
in thread Best perl environment for mySQL server? by Anonymous Monk

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.