in reply to thinking about mod_perl

If you are building your application using perl, then there is no reason not to consider mod_perl. It is simple to write your applications so that they work both as plain CGI scripts and work correctly under mod_perl. All you need to do is follow the safe coding guidlines that mod_perl suggest when building your application. Most of these suggestions are good coding practise anyway and will result in better code.

A good start is to always use strict, and to use a good framework for building your application. I personally use CGI::Application which goes a great job of organizing your code, and is fully compatible with mod_perl.

Read the docs at http://perl.apache.org/, and checkout the CGI to mod_perl Porting. mod_perl Coding guidelines.

Of course mod_perl offers a huge amount more then just speeding up your CGI scripts, but I would suggest starting simple...

- Cees

Replies are listed 'Best First'.
Re: Re: thinking about mod_perl
by geektron (Curate) on Jul 19, 2003 at 17:32 UTC
     use strict; flies onto the screen right after the proper #! declaration for me.

    I'm partial to Template::Toolkit for systems ... that way everything becomes *roughly* MVC, and is easier for me to debug . display problems are in one place, logic problems in another.

      My reason for using CGI::Application also stems from trying to follow the MVC pattern. CGI::Application acts as the Controller and suggests using HTML::Template for the Views (although many people use TT in place of H::T). For the Model I usually create Class::DBI modules of my tables and litter them with many helper functions.

      The other reason why CGI::Application is so good to use with mod_perl is that the actual CGI script is very small. All of the code is put into modules. The reason this is important when using mod_perl is explained by tilly's comment above. The actual CGI script is only a couple of lines long and hence you will not have problems with the "Cannot stay shared" issues that many legacy CGI scripts suffer from.

      I'm not trying to turn this into a 'My Way is better than Your Way". But something you should get out of this, is that it is very beneficial to place the majority of your code into modules instead of building a monolithic script littered with functions, especially when you are using mod_perl.

      - Cees

        moving code into modules is an approach i agree with entirely. and it's even more important when/if i move to mod_perl, so you're preaching to the choir on this one.