[Pdx-pm] Newbie question about data structures and stacks and recursion

Eric Wilhelm scratchcomputing at gmail.com
Wed Nov 30 13:32:51 PST 2005

# from Keith Lofstrom
# on Wednesday 30 November 2005 01:11 pm:

>I want to build a recursive subroutine for exploring a branching
>decision tree, and I would like to glom together a bunch of scalars,
>arrays, and hashes into a data structure of some kind and push them
>onto a stack at the beginning of a routine, and pop them off after.

I've never seen a really good way to abstract this out into a reusable 
form, so I always end up rewriting the recursion stuff around whatever 
algorithm.  Unfortunately, HOP is not available online yet.


In any case, if you're reusing recursion code, you'll have to give it a 
callback for each node on the tree (ala File::Find IIRC.)  Do any of 
these work that way?


Or maybe something instructive in Data::Dumper (if there's a pure perl 
version in there anywhere.)

And I would have hoped that this at least had some kind of callback in 


So, which module has the  the walk($data, {callback => sub {...}, 
array_callback => sub {...}, ... }) routine?

"It is a mistake to allow any mechanical object to realize that you are 
in a hurry."
--Ralph's Observation

More information about the Pdx-pm-list mailing list