Package lexicals declared with my in the main block of a package using AutoLoader will not be visible to auto-loaded subroutines, due to the fact that the given scope ends at the __END__ marker. A module using such variables as package globals will not work properly under the AutoLoader.
The vars pragma (see "vars" in perlmod) may be used in such situations as an alternative to explicitly qualifying all globals with the package namespace. Variables pre-declared with this pragma will be visible to any autoloaded routines (but will not be invisible outside the package, unfortunately).
The vars pragma sounds risky, but I thought that using "my" in the main block as globals for subroutines was standard practice. Am I wrong (perhaps there should be no such "globals" for subroutines, and everything needed to produce the subroutine's result should come in as a parameter; or use "our")?
In reply to Re^2: Can perl modules be compiled?
by davebaker
in thread Can perl modules be compiled?
by mad_ady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |