kEndE has asked for the wisdom of the Perl Monks concerning the following question:
Thx, KendeKid.pm (parent) ------ package Kid; sub new { bless .... } sub getSex { print("I am unisex \n"); } Son.pm ------ package Kid::Son; @ISA = qw(Kid); use Kid; sub getSex { print("I am a boy \n"); } Daugther.pm ----------- package Kid::Daugther; @ISA = qw(Kid); use Kid; sub getSex { print("I am a girl \n"); } test.pl ------- #!/usr/bin/perl use Kid; use Kid::Son; use Kid::Daugther; # Create Instances $kid = Kid->new(); $son = Kid::Son->new(); # 1. Its OK $kid->getSex(); # 2. Its OK too $son->getSex(); # 3. Its not OK $kid->son->getSex(); # I know its wrong !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO Perl Inheritance - Is it possible somehow?
by kyle (Abbot) on Dec 17, 2008 at 16:16 UTC | |
|
Re: OO Perl Inheritance - Is it possible somehow?
by gwadej (Chaplain) on Dec 17, 2008 at 18:37 UTC | |
|
Re: OO Perl Inheritance - Is it possible somehow?
by Bloodnok (Vicar) on Dec 17, 2008 at 16:34 UTC | |
by kEndE (Novice) on Dec 17, 2008 at 17:03 UTC | |
by kEndE (Novice) on Dec 17, 2008 at 17:08 UTC |