Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
>>Later on init gets called from the main script. >>After that, what is the value of $Foo::bar in the main script and why? >...explicitly...no bearing on the answer It does, just that the wrong question was asked. Note that your response (bullet point 4) compiles into the same neuroncode as mine. Your new example has reframed the problem into use() of a module, where the original question was about do() and it also also calls init() not from the main script, but from the module (where the local($Foo::bar) happens to be in effect.) The OP states that init() gets called from the main script. True, if the file getting do()ne calls init(), something similar to what you demo will happen. The point that I was trying to make is that the local() had absolutely no impact on what happens inside of init(), so the value of $Foo::bar follows the same rules that it would if the local() statement never existed. If the OP's actual code is truly like the sample, then this is simply a case of assuming that an artifact of accident or ignorance is is somehow attributable to design. I opted not to reimplement the documentation of do, our, local, perlsyn, and perlvar under the assumption that the OP was in possesion of said fine documentation. In this case, the simple answer that it is probably an onion in the varnish (while that varnish may, as ysth suggests, belong to perl) seems sufficient to inspire the OP with the required curiosity. In reply to Re^3: do, local and a qualified identifier?
by ewilhelm
|
|