Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I ran into a case in a module where I had 'use vars' and I changed it to 'our' causing it to break.
It was in an export module that exports a variable to the caller's package. I had: and had changed it to: As a sample varname, I had 'Tor_mgr' being exported back to the using prog. After the change, in the using prog, I got: What I think was happening, is that the processing of the module didn't happen until after the prog had already been through the 'BEGIN' stage, so this module couldn't insert the 'our' definition in the package's namespace before its usage, so in the 2nd pass, perl saw $Tor_mgr which it now new to be defined later on, but didn't see it in an EXPORT array in the used module (I'm guessing). Anyway, since the 'use vars' was in the first version, that defined it in a non-lexical scope, which passes the 2nd pass's checks. It may be that the module could be rewritten to not need use vars, but it doesn't look straight forward. FWIW, the module being used, exported variable names with values corresponding to found paths of their lower-case names as executables, so any EXPORT list would be variable per usage (though fixed per program invocation). In reply to Re^2: Is 'use vars' really obsolete?
by perl-diddler
|
|