Re: localized lexical varibles

[prev] [thread] [next] [Date index for 2005/03/15]

From: Vladimir D Belousov
Subject: Re: localized lexical varibles
Date: 19:27 on 15 Mar 2005
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.
>

localized lexical varibles
Vladimir D Belousov 17:29 on 15 Mar 2005

Re: localized lexical varibles
Michael Peters 17:30 on 15 Mar 2005

Re: localized lexical varibles
Vladimir D Belousov 19:27 on 15 Mar 2005

Re: localized lexical varibles
Perrin Harkins 23:59 on 15 Mar 2005

Re: localized lexical varibles
Tom Schindl 17:40 on 15 Mar 2005

Re: localized lexical varibles
Vladimir D Belousov 18:54 on 15 Mar 2005

Re: localized lexical varibles
Michael Peters 18:59 on 15 Mar 2005

Re: localized lexical varibles
Vladimir D Belousov 19:41 on 15 Mar 2005

Generated at 16:59 on 18 Mar 2005 by mariachi v0.52