CGI::Application was Re: easy introduction to perl

Steve Mynott steve at
Sat Oct 6 22:26:14 BST 2007

On Sat, Oct 06, 2007 at 09:19:42PM +0100, David Cantrell typed:

> I'd hardly call CGI::Application "advanced".

Well I don't really care whether modules are "advanced" or not 
(whatever that means).  I prefer "useful" ones.

I've used CGI::App and I like it.  It scratched my itch.

It takes care of much of the boring CGI stuff automatically and
in a simple obvious way.

> Catalyst might be, Mason might be, I have no idea what Jifty is, but
> CGI::Application is just a slightly more wordy way of writing this:
> if($action eq 'foo') {
>   ...
> } elsif($action eq 'bar') {
>   ...
> } elsif($action eq 'baz') {
>   ...
> }

Well thats the sort of thing I used to really hate about CGI
but CGI::App makes it less wordy not more wordy.

This would be represented as:

use CGI::Application::Plugin::AutoRunmode;

# methods tagged with the "Runmode" attribute 
# which is taken from the "rm" CGI parameter automatically

sub foo : Runmode {
    my $self = shift;

sub bar : Runmode {

sub baz : Runmode {

Cleaner than an ugly "if elseif" condition IMO.  Basically the 
C in MVC.   An example of this being more wordy would be representing it
in XML (as I believe some Java MVCs do).

There are a large number of plugins available for CGI::Application, often the
sign of an excellent module, including ones for Template Toolkit, CGI session
and the usual ORMs etc.

Steve Mynott <steve at>

More information about the mailing list