angel flower wrote: > With mod_perl, each subroutine in every Apache::Registry script is > nested inside the handler subroutine.
That's true, but it didn't contribute to your problem. What Stas was referring to in that writeup was a sub that is already nested before you run it under Apache::Registry, like this: sub print_power_of_2 { my $x = shift; sub power_of_2 { return $x ** 2; } my $result = power_of_2(); print "$x^2 = $result\n"; } The "power_of_2" sub here is nested, and running it inside Registry makes it doubly nested. That's not the problem you had though. > So increment_counter() is a nested > subroutine of handler().When I declare vars with 'my' outside of nested > subroutine,the problem happened.That's the reasons. No, the same thing would happen in a normal perl program with no nested subroutine. Making a sub that refers to a lexical variable declared outside of its scope will ALWAYS create a closure. You just don't normally notice this when running under CGI because your program exits after a single run and you never see the persistent value of the lexical variable. - Perrin