Steve,

If you were not using mod_perl 1.x in your old cgi programs, you probably don't need 
to be using any of the request stuff.  ModPerl::Registry does all the voodoo for you 
for ordinary cgi programs.

The stuff below is full of extra stuff and may not be 100 percent, but it works. This 
is what my setup evolved to when I migrated to mod_perl 2 from 1.3.  This may get you 
going so you can experiment.  The docs on perl.apache.org can clarify things for you.  
The porting docs (http://perl.apache.org/docs/1.0/guide/porting.html) should be 
helpful if you already know how to write perl cgi programs.  That is a 1.0 doc so 
don't use server configuration info from there.  Start with a hello world program and 
work your way up.  Variables need to be done correctly (porting guide).  

==> 1.   Ordinary cgi programs can run with a startup like this (don't know where all 
that stuff comes from but it works.  Last three lines of code are specific to my 
application):

use Apache2;
use ModPerl::Util ();
use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::RequestUtil ();
use Apache::Server ();
use Apache::ServerUtil ();
use Apache::Connection ();
use Apache::Log ();
use Apache::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
use Apache::compat ();
use ModPerl::Registry ();

use lib 'e:/Apache2/cgi-perl/common';
use lib 'e:/Apache2/cgi-perl/sims';
use lib 'e:/Apache2/cgi-perl/vw';
1;


==> 2.   A config that has these lines in it:

LoadFile "e:/Perl/bin/perl58.dll"
LoadModule perl_module modules/mod_perl.so


ScriptAlias /cgi-perl/ "e:/Apache2/cgi-perl/"

Alias /perl/ "e:/Apache2/cgi-perl/"

PerlRequire "e:\Apache2\conf\startup.cgi"

  <Location /perl>
     SetHandler perl-script
     PerlResponseHandler ModPerl::Registry
     Options +ExecCGI
     PerlOptions +ParseHeaders
  </Location>

==> 3.   Then, a cgi that starts with this:
#!c:/perl/bin/perl.exe -w
$| = 1;
use warnings;
no warnings;

use strict;
use CGI qw/:standard :html3/;
use Apache::DBI();


The folks on the list use the "handler" but I haven't found a need to go to it.  I 
just use ModPerl::Registry to get fast performance and object caching.  There is a 
whole lot more in there for those that venture in.  My ModPerl::Registry based stuff 
is running reliably on Apache 2.

Hope this helps.
Chuck




-----Original Message-----
From: Steven Scotten [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 16, 2004 5:20 PM
To: [EMAIL PROTECTED]
Subject: newbie confused, documentation seems contradictory and/or
incomplete.


Hello, and thanks in advance for your patience as I ask how to do 
something rudimentary, but I seem to be rather dense and a week up to 
my eyeballs in documentation has left me no closer than when I began.

My problem is that I'm trying to pick up mod_perl2 without ever having 
used mod_perl before. I've got a ton of scripts in perl using CGI.pm, 
and I don't mind doing a bit of rewriting; some of that code is very 
old, and it's a good excuse to go back and clean up.

Most of what I've read suggests that what I've been doing with CGI.pm 
should be replaced by Apache::Request. In fact, my module that uses 
CGI.pm throws errors when included in startup.pl:

   Can't locate object method "new" via package "CGI" (perhaps you 
forgot to load "CGI"?)

...which it doesn't do if I leave the module out of startup.pl and just 
use it in individual scripts. I have "PerlModule Apache2 CGI DBI" in my 
/etc/httpd/conf.d/perl.conf file, so I don't need to use() it. I've 
been led to understand that there is a performance benefit to including 
frequently-used modules in my startup.pl file, and I'd like to take 
advantage of that benefit.

So I've set to trying to replace CGI.pm entirely in one particular 
module. It looks as though Apache::Request would have been my path in 
mod_perl 1.x and I've been looking at 
http://perl.apache.org/docs/2.0/user/porting/compat.html (among other 
places) for what to do.

Under $r->request it says "Use Apache->request".

Under Apache->request it says "Apache->request usage should be avoided 
under mod_perl 2.0 $r should be passed around as an argument instead"

...so I'm stumped.

The docs for 2.0 don't seem as complete as the docs for mod 1.0, which 
makes perfect sense since 2.0 seems to still be not quite complete. But 
it's pretty difficult to keep track of what from the 1.0 docs applies 
to 2.0 and what doesn't. All things being equal, I'd really rather 
learn the current ways than to learn the old ways and immediately 
unlearn them. But I need a bit of guidance here.

My apologies, I seem to be unclear on a number of concepts here, and 
it's hard to get enough reference points to form a foundation to help 
me put this all together. I'll appreciate even being told what an idiot 
I am, as long as I get a little closer to a clue.

My system is Fedora Core 1, Apache/2.0.49 (Magic Number: 20020903:7) 
installed from RPM (httpd-2.0.49-1.1) and mod_perl-1.99_14 compiled 
from tarball (it had been installed from RPM, but I read that I 
shouldn't even bother asking questions on this list unless I had the 
most current version, and doing an RPM ugrade to 1.99_14 from 1.99_12 
broke everything, so I rpm -e'ed it and installed from tarball--it 
works fine now)

Thanks again, and my apologies for not being able to formulate a more 
concise question.


Steve


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to