I actually find CGI::App to be more elegant than a dispatch table, and for the record, i have only recently discoverd CGI::App. I used dispatch tables plenty in the past. In essence, CGI::App is a dispatch table, but one that is tested and ready to go.#!/usr/bin/perl -T package WebApp; use strict; use warnings; use base qw(CGI::Application); use CGI qw(:standard); sub setup { my ($self) = @_; $self->start_mode('main'); $self->mode_param('q'); $self->run_modes( main => 'main', login => 'login', members => 'members', AUTOLOAD => '_invalid', ); } sub main { return start_html('Welcome') . p( strong('Welcome to my website!') ) . end_html() ; } sub login { return start_html('Member Login') . p( strong('Member Login') ) . p('Login below:') . end_html() ; } sub members { return start_html('I am a member-only page!') . p( strong('Members Page') ) . end_html() ; } sub _invalid { return start_html('Invalid Function') . p( strong('Invalid Script Function') ) . p('That fucntion is not valid!') . end_html() ; } package main; use strict; use warnings; my $webapp = WebApp->new(); $webapp->run();
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: Event Handling in CGI
by jeffa
in thread Event Handling in CGI
by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |