in reply to Knowing what works with mod_perl

More questions! Is there a difference between using PerlModule Apache::DBI within httpd.conf and using use DBI; within startup.pl (run as PerlRequire "C:/Apache2/conf/startup.pl" within perl.conf)?

Also, if anybody knows of an excellent resource for learning how to code more of a pure mod_perl script (using the Apache::xxx modules rather than using a module such as CGI::Simple). The sample script created at 'http://server.com/hello' is kind of boggling. Not to mention there is no POD for the modules this is supposidly coming from (Apache::RequestRec for example just does something with Apache::XSLoader). Very confusing for a beginner in the area.

Replies are listed 'Best First'.
Re: Re: Knowing what works with mod_perl
by liz (Monsignor) on Dec 26, 2003 at 12:21 UTC
    Is there a difference between using PerlModule Apache::DBI within httpd.conf and using use DBI; within startup.pl...

    No, I don't think so. You should realize that anything that mod_perl loads, is basically done at runtime with either a require or a string eval. This means that you can have BEGIN {} blocks (because you can have them in a string eval as well). END {} blocks are handled differently.

    ...Not to mention there is no POD for the modules...

    That still is indeed a problem. Patches are welcome. If there is a function with the same name in mod_perl 1.0, and it's not mentioned in the Porting document, you can assume that the API of the function is still the same.

    Hope this helps.

    Liz

    Update:
    Argh... Missed the "Apache::" versus non Apache in your question. Yes, definitely a difference: see bart's answer.

Re: Re: Knowing what works with mod_perl
by bart (Canon) on Dec 26, 2003 at 12:38 UTC
    Is there a difference between using PerlModule Apache::DBI within httpd.conf and using use DBI; within startup.pl (run as PerlRequire "C:/Apache2/conf/startup.pl" within perl.conf)?
    There should be. According to the docs of Apache::DBI, the latter serves to create a pool of permanent database connections, which means it changes the behaviour of DBI. OTOH, when just using DBI, without Apache::DBI, you still create a new connection every time a script runs — even though the module itself remains loaded.