in reply to Re: Extending object you don't create
in thread Extending object you don't create
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Extending object you don't create
by dws (Chancellor) on Feb 28, 2001 at 06:54 UTC | |
by dcorbin (Sexton) on Feb 28, 2001 at 06:58 UTC |