|The stupid question is the question not asked|
Note on usage of ours variables and a questionby likbez (Sexton)
|on Nov 19, 2019 at 22:27 UTC||Need Help??|
likbez has asked for the wisdom of the Perl Monks concerning the following question:
I would like to avoid qualification with package name a variable that I use in many modules in many situations. For example, variable debug.
Looks like I can't use our declaration for this purpose (see below) Does any other mechanism exist?
Also question about 'export" behavior". If I export variable debug from module A does it became "normal variable" in main:: so that I can use it in module B? what will happen if I export it from module b as well ? It should bind it to the same variable, right?
Can anybody enlighten me about this behavior? BTW does Perl have a system variable "debug" that is global and does not need qualification with the package name?
For example, if I created module example.pm it compiles OK, but produces a run time error because Perl assumes that our debug is $example::debug not $main::debug
May be our behavior can be generalized to handle this case as well? Why we can't alias variables in other namespaces? Is not this an artificial restriction?
It complains that it is undefined: