Just another Perl shrine | |
PerlMonks |
Re: Seeking the right way to override global variablesby Athanasius (Archbishop) |
on Sep 26, 2014 at 13:59 UTC ( [id://1102134]=note: print w/replies, xml ) | Need Help?? |
Hello contra-sh, and welcome to the Monastery! I’ll just address one part of your question: Seems like the override only works when I call the function. That's weird because I modified the value before including the logging module. No you didn’t! use logging; is the same as BEGIN { require Module; }, which means that the code in “logging.pm” is loaded and run before the rest of the script begins running (because anything in a BEGIN block is run at compile time). Change that line in “run-unit-tests.pl” to require logging; and the output is:
- Should I see any difference if I use require instead of use? Yes! (as just explained). Hope that helps,
In Section
Seekers of Perl Wisdom
|
|