use CGI qw(:standard);
$page = param('page');
# do some header stuff here
if ($page eq 'list_products') {
# deal with listing products
print "......"
} elsif ($page eq 'view_product') {
# deal with viewing products
} elsif ($page eq 'edit_product') {
# deal with editing products
} elsif ($page eq 'save_product') {
# deal with saving product changes
} else {
# display a default page
}
# do some footer stuff here
####
if ($page eq 'list_products') {
list_products();
} elsif ($page eq 'view_product') {
view_products();
} elsif ($page eq 'edit_product') {
edit_product();
} elsif ($page eq 'save_product') {
save_product();
} else {
start();
}
sub list_products {
print '...';
}
##
##
%pages = (
list_products => \&list_products,
view_product => \&view_product,
edit_product => \&edit_product,
save_product => \&save_product,
default => \&start,
);
if ($pages{$page}) {
$pages{$page}->();
} else {
$pages{default}->();
}
sub list_products {
print '...';
}
##
##
use base qw(CGI::Application);
sub setup {
my $self = shift;
$self->run_modes(
list_products => 'list_products',
view_product => 'view_product',
edit_product => 'edit_product',
save_product => 'save_product',
start => 'start',
);
}
sub list_products {
my $self = shift;
return '...';
}
##
##
use base qw(CGI::Application);
use CGI::Application::Plugin::AutoRunmode;
sub list_products :RunMode {
my $self = shift;
return '...';
}