in reply to Overriding 'static' methods of a perl package
For that to work, sub identify must be written differently, as a class method:
package MyParent; sub identify { return $_[0]->name; }; sub name { return 'MyParent'; # or alternatively, return ref $_[0] || $_[0] }; package Child; use parent -norequire => 'MyParent'; sub name { return 'Child'; # or alternatively, return ref $_[0] || $_[0] };
Update: Also set up inheritance between Child and MyParent.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Overriding 'static' methods of a perl package
by Anonymous Monk on Sep 16, 2008 at 14:46 UTC | |
by Corion (Patriarch) on Sep 16, 2008 at 14:48 UTC | |
by Anonymous Monk on Sep 16, 2008 at 15:18 UTC | |
by Corion (Patriarch) on Sep 16, 2008 at 15:37 UTC | |
by Anonymous Monk on Sep 16, 2008 at 16:07 UTC | |
|