in reply to subroutine recursion question

How about just clearing @big before you make the top the top-level call to walk(). Is that what you want to do?
our @big; # "my" will also work here for my $r (@array) { @big = (); walk($r); # @big lists every node visited by walk($r) ...do something with @big... } sub walk { my $i = shift; push(@big, $i); for (...) { walk($_) } }

Replies are listed 'Best First'.
Re^2: subroutine recursion question
by ikegami (Patriarch) on Jun 20, 2008 at 08:26 UTC
    our??? Without changing anything else, it would work with my.
      Yeah, you're right about that. I have to remind myself that my variables can be shared between subroutines. For some reason, when I encounter that situation I think "global" variable which translates into our.