UPDATE:
An example CGI app of my own to show you a way to structure such an app:
You can see that the app is reduced to a dispatch and just a few lines of code. Everything else is seperated in modules. One for all database-action, one for building queries and one for the templating. Based on the $form->action it receives it calls the related actions using the dispatch table.#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw ( warningsToBrowser fatalsToBrowser ); use DB::Countries; use Templating::Countries; use Query::Countries; # # declaration # my $q = new CGI; my $form = $q->Vars(); my $db = new DB::Countries; my $tmpl = new Templating::Countries; my $dispatch = { 'search' => sub { my $query = new Query::Countries ($form); $tmpl->overview($db->get($query)); }, 'edit' => sub { $tmpl->edit($db->get($form->{'id'})); }, 'new' => sub { $tmpl->add(); }, 'delete' => sub { $tmpl->del($db->get($form->{'id'})); }, 'update' => sub { $db->update($form); $tmpl->default(); }, 'insert' => sub { $db->insert($form); $tmpl->default(); }, 'remove' => sub { $db->remove($form->{'ID_country'}); $tmpl->default(); }, 'default' => sub { $tmpl->default() }, }; # # main # print $q->header(); print $dispatch->{$form->{action}} ? $dispatch->{$form->{action}}() : $dispatch->{'default'}(); exit;
In reply to Re: Editing Posted Data
by neniro
in thread Editing Posted Data
by ejx2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |