BluePerl has asked for the wisdom of the Perl Monks concerning the following question:
package person; use Method::Signatures; method new (%args) { return bless {%args}, $self; } method name () { return "*person*\n"; } method myname () { return name() } package eva; our @ISA = ("person"); use Method::Signatures; method name () { return "eva\n"; } my $p = new person (); print $p->name (); my $e = new eva (); print $e->name(); print $e->myname(); # returns: # *person* # eva # *person* 1;
How can I achieve, that $e->myname () returns "eva". Which means, that a direved class calls its baseclass (function myname) and the baseclass should call the name function of the Child class.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO-Perl Question: How to call a derived class from a base class?
by poj (Abbot) on Jul 24, 2015 at 12:21 UTC | |
by BluePerl (Acolyte) on Jul 24, 2015 at 13:20 UTC | |
by dsheroh (Monsignor) on Jul 25, 2015 at 08:27 UTC |