Or, if you need to do this during construction, consider subclassing HTML::TreeBuilder and selectively overriding methods.That won't work if HTML::TreeBuilder has "hard coded" the name of HTML::Element, which I suspect it has.
As a hack, I'd just define methods in HTML::Element's space.
For long term, write the author of HTML::TreeBuilder and tell him to make the subclass an overrideable constant:
because then you can override that:package HTML::TreeBuilder; sub element_class { return "HTML::Element"; } ... sub make_sub_node { ... my $ele = $self->element_class->new(...); #makes an HTML::Element pe +rhaps .. }
.package My::TreeBuilder; use base qw(HTML::TreeBuilder); sub element_class { return "My::Element" }; package My::Element; use base qw(HTML::Element); sub my_additional_method { ... }
-- Randal L. Schwartz, Perl hacker
In reply to Re: Re: Extending object you don't create
by merlyn
in thread Extending object you don't create
by dcorbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |