Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
global variable initialization inside try{}by legova (Novice) |
on Apr 09, 2009 at 14:28 UTC ( [id://756613]=perlquestion: print w/replies, xml ) | Need Help?? |
legova has asked for the wisdom of the Perl Monks concerning the following question: I have a script that calls a function in a module, and inside the module a global variable is defined. The function in the module tests the value of the global variable inside a try{} block. When the global is declared using "my", the variable is undefined inside the try{}. If I change the declaration to "our", or access the variable outside the try{} but inside in the normal scope of the function, then the variable is defined correctly. It seems like the initialization of the variable is optimized out, that the code in the try{} isn't analyzed when the function is initialized. I am trying to understand why this is the case, and whether this is expected behavior or not. Using Perl 5.8.3. Thanks, Calling script:
Module: global_stuff.pm:
Back to
Seekers of Perl Wisdom
|
|