Michael Peters wrote:
Vladimir D Belousov wrote:
[skipped]
You're creating a closure with $s and $r. Check out http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Understanding_Closures____the_Easy_Way
to understand why this causes strange behavior.
Thank you! I searched for the similar document, but probably again not there.
You wouldn't normally notice this under normal perl since the interpreter gets reloaded and your scripts get re-compiled on each run. mod_perl doesn't recompile your scripts for each run thus letting you see this behaviour that actually exists in perl itself.
I see. Thanks!
As I know, my module has been loaded only once and has been loaded by the root httpd process.
And when any httpd forks exist (prefork), let's present next situation:
one of the existing httpd forks changes value of any variable (in my example $s).
Whether value in relation to other existing forks will change?
How I understand, the apache creates the new instruction point for each process - the index to the current instruction (standart in Unix, do not load the code again), but where from does it get the variables and any data?
A new stack? No - in this case all variables would be initialized in advance known (prospective) values.
Do all values shared among the existing child process? No - this is the chaos.
Where I wrong?
The easiest/cleanest workaround is to always pass those kind of shared resources to your subroutines as arguments.