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


in reply to scope and declaration in local packages

It's not a scope problem. The problem is that «Animal::Hog->sound();» comes before «my $sound1 = "knor1";» and «our $sound2 = "knor2";». You're basically inlining a module, but you're not properly emulating «use». To do so, use

BEGIN { package Animal::Hog; ... $INC{'Animal/Hog.pm'} = __FILE__; }

In this case, you can avoid doing the last statement. Simply adding «BEGIN» would do the trick.