Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I'm trying to port a system to mod_perl. Basically, I've got a 'global.pl' script that I require() from my other scripts to load functionality such as cookies, DB connections, etc. This is an extract of my global.pl file:#!/usr/bin/perl use DBI; use CGI; use Image::Size; sub env() { $query = $ENV{'QUERY_STRING'}; $cookie = $ENV{'HTTP_COOKIE'}; ($cookiename,$cookievalues) = split(/=/,$cookie); ($cookietype,$cookieuser) = split(/\&/,$cookievalues); $imgpath = "/home/e-smith/files/ibays/Primary/html/departments"; $imgpathweb = "/departments"; } sub form_read() { $q = new CGI; %fr = (); foreach ($q->param()) { $fr{$_} = $q->param($_); } } sub mysql_connect() { $dbh = DBI->connect("dbi:mysql:departments","user","passwd") or die "S +QL Connection Error."; }
So then, from my CGI scripts I can do the following:
#!/usr/bin/perl require '../global/global.pl'; &env(); &mysql_connect(); $sth = $dbh->prepare("select label,notes from departments where depart +ment='$query'"); $sth->execute; ($departmentlabel,$departmentnotes) = $sth->fetchrow_array; $sth->finish; $dbh->disconnect; &form_read(); print $fr{aformfield};
This all runs just fine as plain CGI, but starts crashing under Apache::Registry. Every a couple of reloads, I get an Internal Server Error, and in Apache's error log:
Undefined subroutine &Apache::ROOTdepartments::mod_2dperl::site::department_2epl::env ....
I tried searching the web for solutions, but the information I found is a little confusing.
Anyone knows what should be changed within the code above so that it runs correctly with Apache::Registry?
Any help is really appreciated.
Thanks,
Ralph
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Porting to mod_perl issues
by hardburn (Abbot) on Jun 14, 2004 at 13:34 UTC | |
|
Re: Porting to mod_perl issues
by perrin (Chancellor) on Jun 14, 2004 at 13:50 UTC | |
|
Re: Porting to mod_perl issues
by Anonymous Monk on Jun 14, 2004 at 17:11 UTC | |
by Anonymous Monk on Jun 14, 2004 at 17:33 UTC | |
by Anonymous Monk on Jun 14, 2004 at 17:57 UTC | |
by perrin (Chancellor) on Jun 14, 2004 at 18:24 UTC | |
by Anonymous Monk on Jun 14, 2004 at 19:03 UTC |