in reply to Recursion, tree parsing.
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
|
|---|