![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
For various portability reasons, I need to include a couple of custom packages in the same file as my application.
I have no problem wrapping each package in a BEGIN block and accessing methods the usual way. I can also export subroutines using exporter/import. However, I can't seem to export global variables. My code uses the following paradigm: Running, yields the error 'symbol "$globalVar" requires explicit package name' When I dump the namespace for %main::, I get: So, $globalVar seems to be in the namespace, I just can't seem to be able to use it (unless of course I explicitly address it using its originating namespace location as $MyPackage::globalVar) If I put the package in a separate file and include it using 'use MyPackage', I get the same listing in the %main:: namespace as above but I am then able to access the global error directly without error. Any ideas what is causing $globalVar not to be recognized when the package is in the same file as main?
|
|