in reply to working under mod_cgi and mod_perl

The documentation of ModPerl::Registry says : This module emulates the CGI environment, allowing programmers to write scripts that run under CGI or mod_perl without change. Existing CGI scripts may require some changes, simply because a CGI script has a very short lifetime of one HTTP request, allowing you to get away with "quick and dirty" scripting. .

As far as parameter processing goes, there is no change under mod_cgi or mod_perl, but there are a number of other issues to look into, such as not using global variables since they do not (always) get reset for each request. On the other hand everywhere using lexical variables (my) can get you into even more subtle traps as they might get persisted through closures.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: working under mod_cgi and mod_perl
by Miguel (Friar) on Aug 29, 2007 at 16:18 UTC
    On the other hand everywhere using lexical variables (my) can get you into even more subtle traps as they might get persisted through closures.
    That's exactly my problem. I don't have 'global variables' flying around. Everything is done through methods. But I'm having a lot of troubles with forms and getting the correct values from $Q->params. Under Apache::PerlRun everything works OK, but not on Apache::Registry.
      How are you initializing $Q? I'm assuming it's a my $Q = CGI->new(), but is your code set up so that happens on every execution? I've seen this kind of problem when moving to mod_perl. For example, if you have a method that's returning your CGI object for you, make sure you have an initialization method that sets that at the start of each response.
      perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'