in reply to Re: overridden method - best way
in thread overridden method - best way
package Parent; sub X { my $self = shift @_; print "called Parent::X()\n"; ... } # ------------------- # and in the Child class you specialise this package Child; use base qw(Parent) sub X { my $self = shift @_; $self->SUPER::X(@_); # Call Base class method # local function NOT inherited _X($self,@_); ... } sub _X { my $self = shift; print "called Child::_X()\n"; } # ------------------- # and further down the chain... package GrandChild; use base qw(Child) sub X { my $self = shift @_; $self->SUPER::X(@_); # Call up one level # then do some extra grandchild stuff # local function NOT inherited _X($self,@_); ... } sub _X { my $self = shift; print "called GrandChild::X()\n"; }
Note that I do not want the _X() subs called through the inheritance hierarchy, so I call them directly as functions in the current package.
Regards,
Jeff
|
|---|