perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CraigT <ct8...@yahoo.com>
Subject Re: passing CGI paramters
Date Thu, 05 Jul 2007 15:37:47 GMT

Perrin,

Is what I'm hearing you say is that in the PerlRun environment (and I'm
guessing the mod_perl environment too), anything that a subroutine uses
coming from outside that code must be passed as a parameter like
'&sub($paramter)'.   Am I correct in this.    

Associating the words scope and closure helped.   I know scope well although
different languages implement the idea differently.   I had not heard the
word closure before or had not understood it as scope.

CraigT

  

Perrin Harkins wrote:
> 
> On 7/4/07, CraigT <ct8638@yahoo.com> wrote:
>> In each of the modules, I bring 'str' across with something like my
>> $somevar
>> = $page->param("str") assigning the paramter values to a declared Perl
>> variable.
> 
> Okay, but do you pass $page explicitly to the sub, or do you just
> define it outside the sub and use it?  If it's the latter, you have a
> closure problem.
> 
>> The problem is that what is coming across from the
>> invoking module to the invoked module is incorrect.
> 
> That sounds like a closure problem, where the sub can only see the
> original version of $page.
> 
>> the value of 'str' set in the first invocation
>> persists such that the invocation of the other 2 anchors has the 'str'
>> values from the first invocation.
> 
> That sounds like a closure problem too.
> 
>> And
>> again, it works fine under CGI.
> 
> That sounds like a closure problem too.  You never notice that your
> code has a scoping bug (which is what a closure problem is) in CGI
> because the process exits immediately, and the cached value never gets
> used again.
> 
>> Also, the ENV variables I had in my scratchpad where mistakenly executed
>> under CGI.
> 
> Good, then I think all the mysteries are solved.
> 
>> I would like to understand better the 'no longer shared' message in the
>> error log.
> 
> That's a message that you get when you have closure problem.  It means
> the variable will be cached the first time through and never change
> again.
> 
> All that you need to do to fix this problem is to pass all of the
> variables that your sub needs to the sub when you call it.  If you
> don't understand what I mean, post one of your subs and we'll show you
> how to change it.
> 
> - Perrin
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-CGI-paramters-tf4008753.html#a11448994
Sent from the mod_perl - General mailing list archive at Nabble.com.


Mime
View raw message