perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Gaber" <Brian.Ga...@PWGSC.GC.CA>
Subject RE: param and mod_perl
Date Fri, 13 Jun 2008 19:16:09 GMT

	Using $q was not successful.  Here is what I have done:

use vars qw($q);

$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.

-----Original Message-----
From: Michael Peters [] 
Sent: Friday, June 13, 2008 2:54 PM
To: Brian Gaber
Subject: Re: param and mod_perl

Brian Gaber wrote:
>  One thought, my code is written to use the default object so 
> that I do not have something like $q = new CGI;  Could this be the 
> cuase?

Very well could be.

Doing a "$q = new CGI" means that you will get a new CGI object on every
request, which is what you want. I've never used the function interface
of like you did in your example so I don't know how
handles it behind the scenes (whether it creates a new object on each
request or not). But if I were you, that's probably the first place I'd

Also, just a couple of minor nits to help you out. Instead of "$q = new
CGI" do "my $q = CGI->new()". First off the "my" means it's a local
(lexical) variable.
Always good to have your vars be local unless you know you'll need
something else. And "new CGI" is the indirect object syntax for method
calls which is generally frowned upon since it can lead to problems that
are hard to track down. "CGI->new()" is alway unambiguous.

Michael Peters
Plus Three, LP

View raw message