setting a server variable

2008-06-13 Thread tyju tiui
Hi, I'm new to mod_perl and I'm having some difficulty understanding a few things. I'd like to write an Apache module which authenticates a request based on the URL. I only want the module to deny invalid requests and allow valid requests to be processed as normal. A more specific example woul

Re: CGI.pm param and mod_perl

2008-06-13 Thread Perrin Harkins
On Fri, Jun 13, 2008 at 2:53 PM, Michael Peters <[EMAIL PROTECTED]> wrote: > 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 > CGI.pm like you did in your example so I don't know how CGI.pm handles

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Here are relevant parts of code: use CGI '-autoload'; use DBI(); use warnings; use strict; # Initial declaration and/or population of global script variables use vars qw($q); $q = CGI->new(); open(DEBUGLOG, ">> /tmp/mod_perl_debug.txt"); foreach my $name ( $q->param() ) { my $value = $q->pa

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Dondi, Thanks for the advice. Here is the log output now: The value of region is Atlantic for PID: 44538 The value of set is 0 for PID: 44538 SELECT * FROM atlantic_rr WHERE dept REGEXP '^A' ORDER BY dept, pay_list LIMIT 0, 400 The value of region is Atlantic for PID: 60132 The value of

Re: CGI.pm param and mod_perl

2008-06-13 Thread Dondi Stroma
Brian Gaber wrote: The HTML code that I am selecting looks like this: That's not necessary. What does your perl code look like now? Also, try printing/warning the value of $$, which is the process ID. I think you'll find that the value of your variable stays the same for each process.

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Michael, The fatal errors from yesterday are fixed. When I run this as a cgi-bin it runs fine. The HTML code that I am selecting looks like this: A B ... Etc (for each letter of the alphabet) The value of region is Atlantic <- GOOD The value of set is 0 SELECT * FRO

Re: CGI.pm param and mod_perl

2008-06-13 Thread Michael Peters
Brian Gaber wrote: > Here is the log you asked for: We need a little more context than that. For instance I don't see where it actually has the fatal error you mentioned from the earlier posts. Also, if you could annotate it with what the values of those params "should" be. But the most im

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Sorry, my e-mail client didn't like the line endings of the log. Here is the log agin in a more readable format: The value of region is Atlantic The value of set is 0 SELECT * FROM atlantic_rr WHERE dept REGEXP '^A' ORDER BY dept, pay_list LIMIT 0, 400 The value of region is Atlantic The value of

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Michael, Here is the log you asked for: The value of region is Atlantic The value of set is 0 SELECT * FROM atlantic_rr WHERE dept REGEXP '^A' ORDER BY dept, pay_list LIMIT 0, 400 The value of region is Atlantic The value of deptLtr is I The value of set is 0 SELECT * FROM atlantic_rr WHE

Re: CGI.pm param and mod_perl

2008-06-13 Thread Michael Peters
Dondi Stroma wrote: > I don't see what is so bad about this: > > use vars qw($q); > $q = CGI->new(); > > Even though it's a global variable, you are assigning it a new value, > CGI->new, each time. You're right. I don't normally think about registry scripts since I almost never use them. I was

Re: CGI.pm param and mod_perl

2008-06-13 Thread Michael Peters
Brian Gaber wrote: > 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. This makes me think that maybe your problem is something else... but try below. > What is the recommended approach? Pass a reference to $q? No

Re: CGI.pm param and mod_perl

2008-06-13 Thread Dondi Stroma
Michael Peters wrote: 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. I don't see what is so bad abou

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
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 reco

Re: CGI.pm param and mod_perl

2008-06-13 Thread Michael Peters
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 =

RE: CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
Michael, 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 simul

Re: CGI.pm param and mod_perl

2008-06-13 Thread Michael Peters
Brian Gaber wrote: > One thought, my code is written to use the CGI.pm > 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'v

CGI.pm param and mod_perl

2008-06-13 Thread Brian Gaber
I have converted a CGI.pm cgi-bin script to run in mod_perl as a Registry. On multiple runs I seem to get old values of a param('var'). I have read the documents and understand I need to be careful with global variables. Is there something I need to be aware of when I use CGI.pm params? One thou

RE: mod_perl2 newbie DBI question

2008-06-13 Thread Brian Gaber
Michael, Thank you very much for this valuable advice. Cheers. Brian -Original Message- From: Michael Peters [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2008 3:05 PM To: Brian Gaber Cc: Jim Brandt; modperl@perl.apache.org Subject: Re: mod_perl2 newbie DBI questi