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.
Not necessarily. The two are quite close functionality-wise, but Apache::Request is much faster as it's written in C. mod_perl 2.0 requires Apache::Request 2.0, which is in beta now. You can get it from
http://httpd.apache.org/apreq/. Though if you are new to this area, I'd advise to use CGI.pm at the moment and move on to Apache::Request when it's finished (which should be pretty soon). Though do give it a try and see if it works for you, since if people don't try it and don't report problems, it'll take longer to get it released.
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"?)
You create new CGI objects at request time, not at the server startup.
...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.
No, you still need to use() it. It's because use = require+import. Take a look at: http://perl.apache.org/docs/1.0/guide/config.html#The_Confusion_with_use___in_the_Server_Startup_File
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.
There is no contradiction here. Both items tell you how to move from mp1 to mp2. recent CGI.pm versions accept $r as an argument. mentioned here:
http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache_E_gt_request_
Also make sure that you read: http://perl.apache.org/docs/2.0/user/coding/coding.html#Getting_the_C__r__Object
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.
You don't need to apologize, Steven, just ask questions and eventually the gaps in the 2.0 will be filled out, hopefully with help from folks like yourself. It probabaly doesn't help much, but when mp1 started there were no docs at all, so mp2 starts in a much better shape.
What really needs to be done is for someone to take the lead on porting mp1 docs to mp2 docs. Most of those docs can be ported with very minimal changes.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- 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