Just another Perl shrine | |
PerlMonks |
Inheritance confusedby exilepanda (Friar) |
on Dec 07, 2015 at 13:02 UTC ( [id://1149575]=perlquestion: print w/replies, xml ) | Need Help?? |
exilepanda has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
I have few files as follow:
MyTest::Base.pm
MyTest::Lite.pm
main.pl
And run the main.pl, I got this output:
The above codes are snapped (and modified) from my real project, and what I am trying to do is to re-interface the class accessing behavior. From the last line of output, this is obviously the chkAccessRight() is calling to my overridden sub from MyTest::Lite but I would expect it calls the chkAccessRight() from MyTest::Base
I already have a solution though: 2. Implement $lite -> tryAccess ( "app1" ); within the MyTest::Lite class, ie. I dont call the SUPER::tryAccess. BUT some other methods are with more relevance to it's SUPER::* methods, so I like to remain calling the methods' super class for their jobs. It there any better workaround out there ? Thanks in advance! ================================================ UPDATE & CONCLUSION: I gave up on the inheritance way, and use the sub AUTOLOAD to return eval "\$self->\{Parent}->$subName\(\@_))". So there will be no more SUPER:: is needed.
Back to
Seekers of Perl Wisdom
|
|