I finally figured it out.
What I really wanted to do was to have my various modules use $main::DEBUG to set their own package global $DEBUG variable.
The problem turned out to be that, even though I set the variable in main
before 'use'ing the modules (packages), it wasn't available at compile time before the modules (packages) were loaded.
The answer was to put the variable in main in a BEGIN block:
BEGIN {
our $DEBUG = 1;
}
The variable was then available in the modules (packages):
my $DEBUG = $main::DEBUG;
<code>
<i>However</i>, $DEBUG was then not available <i>within</i> main!
<br><br>
I don't know the reason for that, but I resolved it by doing this furt
+her down in main:
<code>
my $DEBUG = $main::DEBUG;
It worked fine from there.
"Peace, love, and Perl...well, okay, mostly just Perl!" --me
Apprentice
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.