Re: Scope of Perl Special Variables

2002-05-05 Thread Bill Catlan

Stas Bekman wrote:

 This explains why by default %ENV is set for each request afresh.
 http://perl.apache.org/guide/performance.html#PerlSetupEnv_Off

Great.  Thank you Stas.  Now I know /how/ that happens, but I don't know /why/
the existing inctances' ENV is not clobbered.

My guess is that a localized copy of the %ENV variable is created by the above
referenced process, thus no clobbering of existing instances' %ENV occurs.
Would that be correct?

-Bill




Re: Scope of Perl Special Variables

2002-05-05 Thread Bill Catlan

 I thought that using 'local' would successfully scope those globals to
 within a sub, so you could,k for example, slurp an entire file by doing:

 local $/ = undef;
 my $file = FH;

 Or am I wrong in that?  I use it frequently, and don't seem to have any
 troubles.

 --Jon R.

It is my understanding that that is correct.  I am a novice at mod_perl, but
your experience would seem to match up with my understanding of the Guide.

Local would scope it to within the enclosing block; so you could scope a
variable within a bare block so that it would be local to you package, but
shareable between subs.

# $/ equals default, global value
{
local $/ = undef;

sub { ... # $/ equals undef }
sub { ... # $/ equals undef }
sub { local $/ = \n\n; # localized value for sub }

# $/ back to undef
}
# $/ back to default, global value

-Bill