> If you are just starting with mod_perl, then I would > suggest not jumping > straight into writing Handlers (like the above script is doing). > > There are several ways that you can get mod_perl to execute your > CGI::Application modules: > > 1. The easiest would be using the Apache::Registry module > to run your > current instance script, which should require no changes at all. > > just add the following to your httpd.conf: > > Alias /perl/ /usr/local/apache/perl/ > <Location /perl> > SetHandler perl-script > PerlHandler Apache::Registry > PerlSendHeader On > Options +ExecCGI > </Location> > > (verbatim from pg 42 of Writing Apache Modules with Perl and C by > Lincoln Stein & Doug MacEachern, a must have for anyone > serious about > mod_perl) > > Now you can add your regular CGI based instance script to > /usr/local/apache/perl/ and your code will be running under > mod_perl. > Do a perldoc on Apache::Registry for more info, and read > http://perl.apache.org/guide/ for lots of useful hints on mod_perl. > > 2. You can write a custom handler like Jesse has provided > above. This > is slightly more difficult, but also slightly more > efficient then the > Apache::Registry method (for most people the difference would be > negligable) > > To use Jesse's Perl Handler code, you would have to add a couple of > lines to your httpd.conf file, and add his "handler" subroutine into > your module. > > PerlModule My::CGIApp::Module > <Location /cgiapp> > SetHandler perl-script > PerlHandler My::CGIApp::Module > </Location> > > Now whenever a user calls the URL http://myserver.com/cgiapp Apache > will call the 'handler' subroutine in the module > My::CGIApp::Module, and > all output of that function will be sent to the browser. > > 3. You could use an anonymous handler in your httpd.conf that calls > your module. This has the benefit of not requiring any > code changes to > your Module, however, this looks more complex to anyone browsing the > httpd.conf file and may not be appropriate in your situation. > > PerlModule My::CGIApp::Module > <Location /cgiapp> > SetHandler perl-script > PerlHandler "sub
> My::CGIApp::Module->new()->run(); return OK; }" > </Location> > > This last one should not require any changes to your CGIApp > modules. > Here we are supplying mod_perl with an anonymous > subroutine, which will > be executed when the http://myserver.com/cgiapp URL is > called. It just > creates a new instance of the module and calls the run method right > after. > > > If anyone who has been using perl scripts with Apache and > hasn't looked > at mod_perl, I really recommend you check it out. It is a fantastic > product and has one of the best support groups I have ever > come across > (the mod_perl mailing list). There is ample documentation > to get users > of all levels started (http://perl.apache.org/guide/), and you'll be > amazed at how your scripts will fly... > > Cees Cees, Many thanks for your detailed answer to a newbie question. I implemented #1 above and it took the runtime down from 10-11 seconds to 4-5 seconds...quite an improvement for no code changes! I'm running this on a 100 MHz box with 96 Mb of RAM, so anything under half a minute is plenty fast enough for me. Thanks so much for your help! Andy --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
