Christopher H. Laco wrote:
You're right. This got convoluted. Let's start over.
package MyApp;
my @context;
sub dosomething {
push @context, 'doingsomething';
};
1;
When this module is loaded into MP then given to each child process, for
each request the user makes to a page that calls dosomething(), what is
the INITIAL value of @context before dosomething() is called and alters it?
I'm assuming that it's always () before dosomething() changes it since
it's declared as my.
No, the first time you call this it will be (). Then dosomething() will
become a closure around @context, and when you call dosomething() again
it will still have the old value for @context. If you don't want it to
retain that value, don't make it a closure, i.e. don't reference a
variable declared in the enclosing scope.
- Perrin