in reply to Solving a deep recursion problem

Untested suggestion:
I think the $iter++ is performed too late to be useful.
I would suggest changing to :
iter => ++$iter,
in the recursive call.

     "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom