Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Re: Extending object you don't create

by merlyn (Sage)
on Feb 28, 2001 at 06:42 UTC ( #61262=note: print w/replies, xml ) Need Help??

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:

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 .. }
because then you can override that:
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
    This is easier to pull off than that I thought. HTML::TreeBuilder already makes allowance for building a tree with objects other than instance of HTML::Element.
    my $tree = new HTML::TreeBuilder(...); # now replace 'HTML::Element' with my subclass $tree->{'_element_class'} = 'HTML::MyElementSubclass';

    Or, if this offends your sensibilities, subclass HTML::TreeBuilder, override new(), and invoke INHERITED::new() before resetting the element class.

    This works with HTML::TreeBuilder 3.09.

      Thanks. I didn't realize it had this ability. I will prostrate myself before the altar for a full day :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://61262]
[Perl300]: I found from Super Search, Net::SMTPS or Net::SMTP, MIME::Lite, Email as options
[1nickt]: Perl300 Try Email::Stuffer
[1nickt]: Or for a little more control, Email::Sender:: Simple
[Perl300]: any suggestion on which one might be secure and simplest. I am not doing anything complex, just check some conditions from DB tables and send email to myself (same domain) if conditions are met
[1nickt]: read the doc of the suggestions I just gave
[1nickt]: A lot depends on whether you are sending mail from your local box or using a remote server
[hippo]: Secure in what sense?
[Perl300]: I am sending from remote server
[1nickt]: Then see Email::Sender:: Transport::SMTP
[Perl300]: secure in sense it should not cause any security concerns, create some loop holes.... I don't know much about it but don't want to cause any problem for security guys here

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2017-10-17 15:55 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (233 votes). Check out past polls.