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.
In reply to Re: scope and declaration in local packages
by ikegami
in thread scope and declaration in local packages
by december
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |