imcsk8 has asked for the wisdom of the Perl Monks concerning the following question:
package gadget; use vars qw($VERSION $CLASS); $CLASS = __PACKAGE__; $VERSION = "0.01"; #Generic method, it can (in theory ;-) return an instance of any subcl +ass sub new { #do initialization stuff } sub parse_tag { my ($twig,$elem) = @_; #do stuff }
i don't have problems calling the subroutine from within the subclass (called test), the problem is when i load the subclass (test) into another module and try to make a reference to it, here's the code that causes the problem: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); } sub new { my $class = shift || $CLASS; my $obj = $class->SUPER::new($class); $obj->{test_attr} = "atributo de prueba"; return($obj); } sub test_stuff { my $self = shift; foreach my $a (@_){ print "($self) ARGUMENTO: $a\n"; } }
in here i get this message: Undefined subroutine &test::parse_tagrequire "test.pm"; $twigroots->{test} = \&{test::parse_tag};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reference to a subroutine inside a package
by chromatic (Archbishop) on Jun 02, 2004 at 22:19 UTC | |
by imcsk8 (Pilgrim) on Jun 02, 2004 at 23:46 UTC | |
by tinita (Parson) on Jun 03, 2004 at 11:27 UTC | |
by Happy-the-monk (Canon) on Jun 03, 2004 at 11:40 UTC | |
by tinita (Parson) on Jun 03, 2004 at 11:50 UTC | |
|
Re: reference to a subroutine inside a package
by graff (Chancellor) on Jun 02, 2004 at 23:46 UTC | |
by imcsk8 (Pilgrim) on Jun 02, 2004 at 23:55 UTC | |
|
Re: reference to a subroutine inside a package
by dave_the_m (Monsignor) on Jun 02, 2004 at 22:25 UTC | |
|
Re: reference to a subroutine inside a package
by Stevie-O (Friar) on Jun 03, 2004 at 02:07 UTC |