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