"be consistent" | |
PerlMonks |
Re: private recursive subroutinesby friedo (Prior) |
on May 10, 2007 at 15:39 UTC ( [id://614662]=note: print w/replies, xml ) | Need Help?? |
You can get around that by simply declaring $func as an undefined lexical and then re-defining it as a subroutine. Since the recursive call doesn't get executed until the sub is called for the first time, by that time, $func will contain the code reference. For example,
Yes, I know factorials are a bad example for recursion; it's just the first thing that came to mind. :)
In Section
Meditations
|
|