in reply to @ISA, Inheritance, and Class Methods

I must admit that I too have fallen in the @ISA trap. But I wanted to look at your solution to extending an existing module. Not that long ago I was looking at using an OO module (I honestly don't remember which one), but this module didn't have a destructor. Instead, you were required to call some kind of clean up method, lets call it Class::Finish(). Well, I'm not a big fan of making the programmer call something that Perl will happily do for you (if you call the method DESTROY) and so I thought about how to extend the class to add:
sub DESTROY { my $self = shift; $self->Finish(); }
And the first idea that came to me was your idea of writing a wrapper object. But I didn't like the idea too much. The next idea (and I think this was someone else's idea) was to do it like this:
{ package Class; sub DESTROY { my $self = shift; $self->Finish(); } }
To replace an already existing method you would only need to add no strict and (5.6+) no warnings within the block. As it turns out, and the more advanced have already made this jump, you can just declare:
sub Class::DESTROY { my $self = shift; $self->Finish(); }
Aint it grand? :-)

Replies are listed 'Best First'.
Re (tilly) 2: @ISA, Inheritance, and Class Methods
by tilly (Archbishop) on Mar 13, 2001 at 21:12 UTC
    My solution would be as follows:
    *Class::Destroy = \&Class::Finish;
    which also has the benefit of being a tad faster.