Since Perl subroutine calls are so expensive this approach is often faster than recursion. Use Benchmark or Devel::DProf to be sure.sub parse { my @stack = @_; while (@stack) { my $node = pop @stack; print $node->{data}; push @stack, @{$node->{children}}; } }
-sam
In reply to Re: Recursion, tree parsing.
by samtregar
in thread Recursion, tree parsing.
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |