An example of stack-based code may look like this:
foreach my $element (@list) { # ... process element, search for sub-elements ... splice ( @list, ($depth_first_processing) ? 0 : @list, 0, $subelement ); }
A quick note on this code - The variable $depth_first_processing allows new sub-elements can be either added to the end of the list (breadth-first iteration) or as elements to be iterated through within the next loop (depth-first iteration).
This structure of stack-based iteration has been incorporated into the current version of WWW::SimpleRobot.
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
In reply to Re: Recursion + hash
by rob_au
in thread Recursion + hash
by karmas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |