http://qs321.pair.com?node_id=1131573


in reply to Re^2: recursion basics
in thread recursion basics

Check my first reply for a more detailed explanation, but the short version is that, each time the function calls itself, the caller stops and waits for the "child" function to finish. So none of the instances reach that final return until one of them returns from the first return, then they all finish and hit the second return in reverse order. Something like this:

binary1 calls binary2, stops and waits for it binary2 calls binary3, stops and waits for it binary3 calls binary4, stops and waits for it binary4 returns from the first return line ($n==1) binary3 finishes, returns binary2 finishes, returns binary1 finishes, returns print statement executes, printing binary1's return value

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.