Re: [cricket-users] mod_perl

From: roofpig@the.satanic.org
Date: Thu Jun 10 1999 - 11:29:42 PDT


From: roofpig@the.satanic.org

On Wed, 9 Jun 1999, Jeff Allen wrote:

> From: Jeff Allen <jra@corp.webtv.net>
>
> Joe Warren-Meeks wrote:
> > However I am trying to get away from using cgi and using mod_perl. From the
> > archives it seems to indicate that mod_perl is suppoorted however
>
> It's never been done, that I know of. I keep trying to find the time,
> but keep failing. :) I'm trying it now, and will tell you what I found
> out.
>

        I worked for a bit on this. Specifically, this URL addresses
the error you refer to:

http://perl.apache.org/dist/mod_perl_traps.html

        I never did get grapher.cgi to successfully run under mod_perl,
because of anther problem mentioned in the same doc. The subroutines
defined in common.pm are created in package main, but as this excerpt from
the above doc says, this can (and does in grapher.cgi) cause some problems
w/ mod_perl:

--- begin excerpt ---
file pulled in via require/use will only happen once per-process (unless
%INC is modified). If the file does not contain a package declaration,
the file's subroutines and variables will be created in the current
package. Under CGI, this is commonly package main. However, Apache::Registry
scripts are compiled into a unique package name (base on the uri). So, if
multiple scripts in the same process try to require the same file, which
does not declare a package, only one script will actually be able to see
the subroutines. The solution is to read perlmodlib, perlmod and related
perl documentation and re-work your required file into a module which
exports functions or defines a method interface. Or something more simple,
along these lines:

     #required_file.pl
     package Test;

     sub some_function {...}

     ...
     
     __END__

    Now, have your scripts say:

     require "required_file.pl";

     Test::some_function();

---- end of excerpt ----

        
        So, it seems that if the subroutines defined in common.pm are
created within a package, and all references to these subroutines are
changed in grapher.cgi to refer to this package, then things will work.

------------------------------------------------------------------------
With more than 20 million e-mails exchanged daily...
http://www.onelist.com
....ONElist is home to the liveliest discussions on the Internet!



This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 19:00:53 PST