http://qs321.pair.com?node_id=895831


in reply to Re: Package Variables
in thread Package Variables

Minor correction - my is block scoped (or more technically speaking "lexically" scoped) with the largest containing "block" (lexical unit) being the file. Example:

use strict; use warnings; package Goo; my $x=100; print "package=", __PACKAGE__, " x=$x\n"; package Boo; { my $x=200; print "package=", __PACKAGE__, " x=$x\n"; } package Foo; print "package=", __PACKAGE__, " x=$x\n"; #outputs package=Goo x=100 package=Boo x=200 package=Foo x=100