in reply to Compile order sanity check
Based on my limited understanding of lexical variables, package variables, and the order of compilation...
If package main is in another file, then you're going to have to use or require the file that contains package noname. Since $globalVariable was declared in noname with my it is a lexical variable, which isn't in the symbol table and isn't visible outside of the scope in which it was declared (i.e., you can't say $noname::globalVariable, as you could if it were declared with our). Therefore, IIUC the only way to access it from another module (package) is through Exporter (or an Exporter-like process), after the module that contains noname is used or required. If that's true then as long as you initialize the variable with your default value before the portion of the module that declares it and exports it returns (during compilation), you'll be OK.
I hope a more knowledgeable monk will gently correct me if I'm wrong. :-)
|
|---|