#!/usr/bin/perl # use strict; use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser set_message); use Data::Dumper; # other modules # error handler BEGIN { sub handle_errors { my $msg = shift; print "
";
$msg =~ s/ (of )*\Q$0//g;
print "$msgEmail me this page";
}
set_message(\&handle_errors);
}
# main program starts here
my $debug = 1;
my $cgi = new CGI;
#put authentication here if required
my $phase = identify_phase()
# $phase = 0 if just printing form otherwise 1 (for complex transactions may return 2, 3 etc.)
print_form() unless ($phase); # this routine probably does not return
my $validref = validate_params()
print $cgi->header, $cgi->pre(Dumper($validref)) if ($debug);
# list example Dumper($validref) output to show what is OK
unless ($validref{error}) {
execute($phase, $validref );
}
else {
report_param_errors( $validref );
}
exit;
# subroutines
# phase 0 if no posted paramters etc etc
sub identify_phase() {
}
sub print_form() {
}
sub validate_params() {
}
sub report_param_errors( ) {
my ($parmref) = @_;
}
sub execute() {
my ($phase, $parmref) = @_;
}