in reply to perl inheritance
Is there a way to accomplish this without overriding all the base class methods?That depends on how the superclass has implemented the methods.
But you may be able to do something like:
foreach my $method (... list of methods to override ...) { eval <<"EOT"; sub $method { my (\$self, \@args) = \@_; my $result = \$self->SUPER::$method(\@args); bless \$result, __PACKAGE__; \$result; } EOT }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl inheritance
by Anonymous Monk on Mar 23, 2012 at 18:38 UTC | |
by JavaFan (Canon) on Mar 23, 2012 at 19:10 UTC | |
by Anonymous Monk on Mar 23, 2012 at 20:21 UTC | |
by tobyink (Canon) on Mar 23, 2012 at 23:06 UTC | |
by JavaFan (Canon) on Mar 23, 2012 at 23:26 UTC | |
| |
by JavaFan (Canon) on Mar 23, 2012 at 20:27 UTC | |
by Anonymous Monk on Mar 23, 2012 at 20:35 UTC |