I am trying to call a perl nested recursive function, but I cannot apply the correct syntax.
Question What is the correct syntax for making a recursive call for a nested function (if nested functions should be called recursively at all)?
Answer: Pay attention to the proposed pseudocode in the accepted answer.
Here is a snippet of pseudocode:
use Scalar::Util; sub outerfunction { my $innerfunction = sub {
I tried calling the internal function as follows (with subsequent error messages):
innerfunction
Undefined routine and main :: internal function
&innerfunction
Undefined routine and main :: internal function
&$innerfunction
The global character $ innerfunction requires an explicit package name
I also tried declaring the inner function local, but I get the following:
The global character $ innerfunction requires an explicit package name
I don't have much experience with interpreted languages, so any random comment related to a memory / stack leak / corruption or other dangers with the indicated pseudo-code would be appreciated (except for system recursion restrictions).
Thanks! perl v5.10.1 runs on Linux 2.6.34.7-61.fc13.x86_64
source share