in reply to sub and anonymous sub
Instead, I prefer passing in a level number to recurse, which means that separate threads calling recurse will not interfere with one another.
I know perl is not thread safe, but perl 6 and/or perl 5.x might be.#(1) sub recurse { #(2) my ($depth) = @_; print +(" .") x $depth . "current depth:$depth\n" ; recurse($depth + 1) if $depth < 3; print +(" .") x $depth . "current depth:$depth\n" ; } #(3) #(4) recurse(0); # (5)
My $0.02 --rW
Update: Gerbil is right. I don't need the extra braces. This is what comes with cutting and pasting someone else's example rather than rewriting from scratch.
Have edited the example to take on Gerbil's suggestions
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: sub and anonymous sub
by Gerbil (Initiate) on Jun 21, 2002 at 22:39 UTC |