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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: scope and declaration in local packages
by december (Pilgrim) on Jan 31, 2011 at 13:42 UTC | |
by ikegami (Patriarch) on Jan 31, 2011 at 15:40 UTC |
In Section
Seekers of Perl Wisdom