in reply to CGI Design

I think we've all been down this path before and found our code wanting for a cleaner framework than nested if-elseif blocks. For this type of scenario, I would strongly recommend looking at CGI::Application (which I have reviewed previously here) - This module offers a very simple, but expansive object-orientated framework that provides some structured order to CGI scripts written in this manner.

The advantage which the CGI::Application interface offers is that individual "run-modes" and execution blocks can be defined, each correlating to a particular stage of your CGI interface. Using the CGI::Application "run-mode" interface, the code above could be re-written as follows - Note that some liberty has been taken with the subroutine names and the example code shortened to reflect only that snippet of code shown above:

sub setup { my $self = shift; $self->mode_param('action'); $self->run_modes({ 'AUTOLOAD' => 'action_dialog', 'add' => 'add_dialog', 'add_commit' => 'add_commit_dialog', 'modify' => 'modify_dialog', 'modify_commit' => 'modify_commit_dialog', 'remove' => 'remove_dialog', 'remove_commit' => 'remove_commit_dialog' }); }

Furthermore, the CGI::Application module implements methods to address the CGI and HTML::Template modules, facilitating powerfule methods for the construction of extensible web applications.

In short, I would strongly look into CGI::Application for this type of application or alternatively, some of the different web application frameworks reviewed by princepawn at Web Application Frameworks and their Templating Engines with a Comparative Study of Template and HTML::Template.

Good luck.

 

Replies are listed 'Best First'.
Re: Re: CGI Design
by Dogma (Pilgrim) on Apr 07, 2002 at 01:41 UTC
    Furthermore, the CGI::Application module implements methods to address the CGI and HTML::Template modules, facilitating powerfule methods for the construction of extensible web applications.

    Well tell me how you really feel about CGI::Application. :) I'll take a look at it, do you know if there are any traps using it under mod_perl?

    Thanks,

    -Dogma

      Nope. I use it extensively with mod_perl and it works beautifully. In fact, if you use this module as it's intended, I think it makes mod_perl programming much easier, as it makes it easy to avoid globals.

      I love the dynamic duo of CGI::Application and HTML::Template. They make it very easy to create flexible and maintainable apps that separate code from content.

      -Any sufficiently advanced technology is
      indistinguishable from doubletalk.