mod_perl and JavaScript

2004-04-08 Thread Kemin Zhou
This is almost certainly caused by a bug in your perl code.  You are
probably unintentionally creating a closure.  If you post some code
here, we can help you spot the problem.
- Perrin
Earlier I posted a problem with HPPTD and mod_perl.
Thanks for Perrin's respons.  

Now I have the problem solved.
The bug is the classical problem with named subroutin inside another subroutine.
This is one shortcoming of mod_perl.  PHP would not have such a problem.

I was using the CGI object as a global variable

my $q = new CGI

do something 

my $request = $q->param('request');
if ($request eq 'updateTable') {
updateDBTable();
}
sub updateDBTable {
my $form_variable = $q->param('variable_name');
}
==
This code would have no problem at all if run as CGI script.
It it will be very bad under mod_perl.
So don't write this.  There are many solutions to this.
One of them is to pass $q as argument of the subroutine.  This is the one I used.


The problem looks as if a caching problem.  Because after the second run, the 
subroutine and the main program the $q-> will point to different forms.

Kemin



**
Proprietary or confidential information belonging to Ferring Holding SA or to one of 
its affiliated companies may be contained in the message. If you are not the addressee 
indicated in this message (or responsible for the delivery of the message to such 
person), please do not copy or deliver this message to anyone. In such case, please 
destroy this message and notify the sender by reply e-mail. Please advise the sender 
immediately if you or your employer do not consent to e-mail for messages of this 
kind. Opinions, conclusions and other information in this message represent the 
opinion of the sender and do not necessarily represent or reflect the views and 
opinions of Ferring.
**
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl and JavaScript

2004-04-09 Thread Perrin Harkins
On Thu, 2004-04-08 at 18:04, Kemin Zhou wrote:
> The bug is the classical problem with named subroutin inside another subroutine.
> 
> This is one shortcoming of mod_perl.  PHP would not have such a problem.

It doesn't actually have much to do with mod_perl.  It's just a coding
mistake, tripping over perl's scoping rules.  It's still a mistake when
writing for CGI, but you wouldn't see it because the interpreter exits
after every request.

PHP has unusual scoping rules.  In order to access a variable declared
in a higher scope in PHP, you have to make the variable global.  If you
were to use a global variable in perl, that would also avoid the closure
issue.

Glad to hear you fixed the problem.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html