Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recursion advice

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I am about to attempt my first recursive application. While researching it there seems to be some caveats with respect to recursion in perl. Does anyone have any general advice about common gotchas with perl recursion? TIA.
 
I quite like recursive applications, and I seem to remember rharsh posted an absolute corker a while back (but I can't seem to find it).

The biggest gotcha is making sure that the 'stop condition' that eventually terminates the recursion is pretty much bulletproof - otherwise you just loop until you run out of memory.

Not all applications are right for recursion. What do you want to do - we might be able to advise on the suitability of a recursive solution...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Thanks for the reply. I'm not too worried about the termination condition. I've written plenty of recursive applications (mostly C) but never with perl. I'm writing an HTML to GED conversion application. Since I want it to go up and down the branches, recursion seems the easiest way to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top