This was a challenge from a coworker.
It presents the shell for a web based wizard, ala Windows 98 wizards -- Presents some information, and "next" and "previous" buttons, and is an extension on
CGI recipe contemplations
use CGI::Pretty qw(:standard);
use strict;
my $current_page;
my %pages = (main => {description =>"Uno",
nextpage =>"page2",
prevpage =>undef,
subname =>\&page1},
page2=> {description =>"Dos",
nextpage =>"page3",
prevpage =>"main",
subname =>\&page2},
page3=> {description =>"Tres",
nextpage =>"page4",
prevpage =>"page2",
subname =>\&page3},
page4=> {description =>"Quatro",
nextpage =>"page5",
prevpage =>"page3",
subname =>\&page4},
page5=> {description =>"Five",
nextpage =>undef,
prevpage =>"page4",
subname =>\&page5}
);
$current_page = param("Current_Page") ||"main";
if (param("Next"))
{$current_page = $pages{$current_page}{nextpage}}
elsif (param("Back"))
{$current_page = $pages{$current_page}{prevpage}}
make_header($pages{$current_page}{description});
param (-name=>"Current_Page", -value=>$current_page);
print hidden ("Current_Page");
foreach my $page_name (keys %pages) {
$pages{$page_name}{subname}->($current_page eq $page_name);
}
make_footer();
exit;
sub make_header {
print header (-type=>'text/html');
print start_html (-title=>shift);
print start_form;
}
sub make_footer {
print p,"<CENTER>";
print submit(-name=>'Back') if defined ($pages{$current_page}{prev
+page});
print submit(-name=>'Next') if defined ($pages{$current_page}{next
+page});
print p"</CENTER>";
print end_form();
print end_html();
}
sub page1{
my $status=shift;
if ($status){
print "this is page1\n";
}
}
sub page2{
my $status=shift;
if ($status){
print "this is page2\n";
}
}
sub page3{
my $status=shift;
if ($status){
print "this is page3\n";
}
}
sub page4{
my $status=shift;
if ($status){
print "this is page4\n";
}
}
sub page5{
my $status=shift;
if ($status){
print "this is page5\n";
}
}