in reply to reference to a subroutine inside a package
First off, why put a BEGIN block inside a package? If you're going to load this as a module via "use test;", then the script that invokes this "use" statement is already handling the package within its own BEGIN block. If you're loading it with "require test;" then I think it's already too late for your package's BEGIN block to be heeded as such.package test; use gadget; use vars qw($VERSION $CLASS); $CLASS = __PACKAGE__; $VERSION = "0.01"; BEGIN { @test::ISA = qw(gadget); @test::ISA = qw(Exporter); @test::EXPORT = qw(parse_tag); }
Second, I would have thought that the assignment to @ISA should go like this:
You're already in "package test" at this point, so having "@test::ISA" seems redundant. But the main point is that in the code you posted, the assignment of "Exporter" to @ISA would appear to replace (obliterate) the preceding assignment of "gadget" to that array.@ISA = qw/gadget Exporter/;
I actually haven't had much practice with OO inheritance, but just in terms of basic Perl syntax, you may want to take a closer look at these things (and let me know if I'm wrong). Good luck.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reference to a subroutine inside a package
by imcsk8 (Pilgrim) on Jun 02, 2004 at 23:55 UTC |