use strict; { package a; my $foo = 1; sub foo { $foo } } { package b; my $otherpkg = "a"; print $otherpkg->foo, "\n"; }