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).sub a { # stuff sub b { # more stuff } }
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 reply to Re: Nested Classes
by arturo
in thread Nested Classes
by dcorbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |