> -----Original Message-----
> From: Damien Delhomme [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 30, 2002 11:45 AM
> To: [EMAIL PROTECTED]
> Subject: Has Perl extra memory!?
> 
> 
> Hi everybody!
> 
> One of my program generates a HTML formulary whose number of 
> checkboxes fluctuates (they are named mod_0, mod_1, mod_2, 
> mod_3...etc).
> Therefore I need a loop in my other program which has to read 
> the formulary :
> 
> my $count ;
> for ($count=0; $count <= $num; $count++)
>         {
>         my $mod = $cgi->param("mod_".$count) ? 
> $cgi->param("mod_".$count) : ""  ;
> 
>         if ($mod ne "")
>                 .....................etc
> 
> ($num is the number (-1) of checkboxes and it is stocked in a 
> hidden inputin the Web page)
> 
> Unfortunately it seems that Perl memorises the values of 
> these "$mod_i" and doesn't always execute the script with the 
> values that are given to it!!
> I have tried differents ways of declaring these parameters 
> (our, my, local, outside or inside the loop...etc) and there 
> has always been the same problem.
> Basically the first formulary you fill is well executed, and 
> after that there is no way to tell when it'll start to bug! 
> Sometimes it executes the formulary you have filled three or 
> four times before!
> 
> I hope someone could help me with this, this problem is 
> poisoning my programs!

Read here:

<http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Registr
y_secrets>

Short rule of thumb I have devised to avoid this problem:

Anywhere you have a file-scoped lexical in your script, like

   my $foo;

Change that declaration to:

   our $foo;
   local $foo;

This only applies to file-scoped lexicals. "my" variables declared inside
subs or blocks are fine. For details on why this happens and why changing it
to a global fixes the problem, read the mod_perl guide.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to