![]() |
|
Welcome to the Monastery | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Ovid,
Every time Perl enters a sub (normally), it creates a new stack frame and this quickly eats memory. Presumably, you are referring to &sub as the abnormal example where you could use goto &sub to bypass the recursion limit as seen in the following example: According to TimToady, this actually does create a new stack, but only after the old one is stripped off. Of course you could always ignore the warning, turn off the 'recursion' warning, or recompile Perl to avoid the warning. In practice, I have never needed this kind of technique because it seems that iterative solutions aren't that difficult to come up with. In this case, the formula (n^2 + n) / 2 would do the trick. And as I am previewing this, I see BrowserUk has already said something similar - oh well. Cheers - L~R In reply to Re^5: Who's a thief? (recursion limitations)
by Limbic~Region
|
|