I read Coping with Scoping, wow what a great read .. I wish it had mentioned Modules as well.
That was outside the scope of that node :-)
But really packages don't interact very strongly with scoping. A package declaration really doesn't affect lexicals in any way.
package First;
my $x;
package Other:
print $x; # still the same $x
Since our declarations really just provide lexical aliases for global storage locations, they interact in the same with packages as lexicals do - not at all. (Only the global storage location depends on the current package).
package First;
our $x;
package Other:
print $x; # still the same $x
Only the fact that many packages live in files on their own affect scoping: each file is a scope of its own.
|