Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^2: my() and our()by DrWhy (Chaplain) |
on Aug 09, 2005 at 22:08 UTC ( [id://482448]=note: print w/replies, xml ) | Need Help?? |
There are actually uses (well, at least one that I can think of) for our beyond use 'strict' context. I have had occasion to use our at the top of a file that contained multiple packages so that I could have a package global that was accessible without full qualification throughout the file. E.g.:
When run, this code prints Xglobal even though the reference to $global is in package Y's space and it was defined as being a global in package X. The our makes all unqualified references to the variable be assumed to be in the X package namespace even after you move into a different namespace. The same effect can be obtained with my(), except that then the variables are not accessible to other perl code that uses/requires this code.
--DrWhy "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
In Section
Seekers of Perl Wisdom
|
|