more useful options | |
PerlMonks |
Re^4: Is 'use vars' really obsolete? (use vars mechanics)by LanX (Saint) |
on Sep 22, 2017 at 12:00 UTC ( [id://1199909]=note: print w/replies, xml ) | Need Help?? |
> I'd say it's globally effective whenever the same package is chosen. Basically yes. I had a look into the code of vars and found this discussion Confused by symbol table import mechanism of 'use vars' What's happening is a "fake" import: *Target::x = \$Target::x; Importing means that in the symbol table of the target package a glob is assigned to an external reference. But in this case it's just a self reference to its own package. (Granted, this looks a bit confusing... *) Like this strict doesn't complain when seeing an unqualified $var inside package Target because it's already imported into Target's STASH. To answer the OP, this has global effect while our is tightly scoped. And the use case you've shown is just a quite complicated way to export.
Cheers Rolf
*) the symbol table decides which variables, functions, file handles and formats are known to the package without needing to be fully qualified.
In Section
Seekers of Perl Wisdom
|
|