I guess to be really pedantic that should be it shares a copy with stuff declared in the same scope at the same time.but functions declared on entering the same scope later get their own set of shared variables. I take your point though and stand corrected.
I read CountZero's reply and I now understand the OP's concern but I don't see that debugging a variable that has leaked into a closure is any harder than debugging the same problem with regular functions.
and in most cases the closures are declared together so it is probably easier to spot.my $var; sub the_first { $var = func1(); } # many, many lines of code later sub the_second { $var = disfunction(); }
I think the answer is to be careful with variables, restricting them to as small a scope as possible and to have as few as possible with file scope.
In reply to Re^4: Catching closures
by hipowls
in thread Catching closures
by bduggan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |