hello monks, i'm having a problem trying to reference a subrotine that is inside a package that maintains an ISA relationship with other package. after here i'm gonna refer to the packages as classes (because that is the conceptualization i'm using) the subroutine (called parse_tag) is declared in the super class (called gadget), this class does not EXPORT any of it's methods (because i want them to be only accesible from the class and subclasses scopes). here's the code of both classes (simplified):
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 }

and the child class code:
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"; } }
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:
require "test.pm"; $twigroots->{test} = \&{test::parse_tag};
in here i get this message: Undefined subroutine &test::parse_tag
i know that is some referencing stuff, but i'm kind of confused, any help will be greatly appreciated.
thanks.


ignorance, the plague is everywhere
--guttermouth

In reply to reference to a subroutine inside a package by imcsk8

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.