I just did as you suggested.
Now in the log I get a
Variable "$q" will not stay shared at ...
error from the $q->param('deptLtr') in the subroutine.
When I read the mod_perl docs they suggest that use vars was one
approach to fix the "Variable X will not stay shared at" error.
What is the recommended approach? Pass a reference to $q?
Thanks
-----Original Message-----
From: Michael Peters [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2008 3:21 PM
To: Brian Gaber
Cc: [email protected]
Subject: Re: CGI.pm param and mod_perl
Brian Gaber wrote:
> Using $q was not successful.
That's because you ignored my advice :)
> Here is what I have done:
>
> use vars qw($q);
That makes $q a global. Bad, bad, very bad. Slap yourself on the wrist.
Remove that "use vars" line.
> $q = CGI->new();
Now replace that with
my $q = CGI->new();
> sub print_form {
> my $dept2show = 'A';
>
> if ( $q->param('deptLtr') ) {
> ($dept2show) = $q->param('deptLtr') =~ /^([a-zA-Z]{1})$/;
> }
>
>
> I am running this script simultaneously on two PCs. Sometimes
> $dept2show has the expected value, but often is has the an old value.
This is because Apache is using multiple processes to handle things.
Sometimes you're hitting a process for the first time, so it creates an
new CGI object and all is well. But sometimes your request goes back to
a process that has already loaded and executed this code before, so $q
is not a new CGI object.
--
Michael Peters
Plus Three, LP