The stupid question is the question not asked | |
PerlMonks |
Re: Nested Classesby arturo (Vicar) |
on Mar 02, 2001 at 19:12 UTC ( [id://61804]=note: print w/replies, xml ) | Need Help?? |
If this is a question about inheritance, yes, Perl supports method inheritance. Put @ISA = qw(Parent); in the child class (see perldoc perltoot or perltoot, or check the Tutorials on this site). What I'm not understanding, though, is the notion of a "subroutine within a method." In Perl, a method IS just a special kind of subroutine (one that expects an object as its first argument), and no subroutine can contain a subroutine (well, you can do , but b has the same scope as a. I suppose you could have a code ref (reference to an anonymous subroutine) defined within a subroutine, but then the only way you're going to get at such a beastie outside the method under normal circumstances is to have the coderef returned by the method (note: if you have a coderef visible outside of the method, then the subroutine is not really contained in the method either). If you want to use the anonymous sub from outside the object's inheritance hierarchy (or on its own from within the inheritance hierarchy), you're probably better off using the Real Coder© 's method of code re-use, which the uninitiated call "cut n' paste" =) Does that help? Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In Section
Seekers of Perl Wisdom
|
|