package X; our $global = 'Xglobal'; ... more stuff here ... package Y; print $global;
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 reply to Re^2: my() and our()
by DrWhy
in thread my() and our()
by dsb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |