D
Don Stefani
Don Stefani humbly exposes his stupidity to the world...
Hello,
Looking at the Perl Cookbook: (Recipe 19:12 Writing a Multiscreen CGI Script)
I'm trying to do this:
<code>
%States = (
'Default' => \&front_page,
'Shirt' => \&shirt,
'Sweater' => \&sweater,
'Checkout' => \&checkout,
'Card' => \&credit_card,
'Order' => \&order,
'Cancel' => \&front_page,
);
if ($States{$page}) {
$States{$page}->(); # call the correct subroutine
} else {
no_such_page();
}
</code>
But I can get the following to work. just fine, but 'The Cookbook' calls my method,
"tedious and clumsy". I'm trying to work away from that! ;-)
I'm testing with just two views, but I'll probably end with six or so.
I must admit I only kind of know what I'm doing. I'm sure that's the key to the problem.
I have a feeling I might be making things too complicated. A good hint and a flaming kick
in the pants are very welcomed. TIA - Don
<code>
#!/usr/bin/perl -w
use strict;
use CGI;
use Lib::AccountMgrGeneral;
use Lib::MysqlModule;
use Lib::WebForms;
my $q = new CGI;
my $amg = new AccountMgrGeneral;
my $mysql = new MysqlModule;
my $wf = new WebForms;
my $view = $q->param('view') || 'srch';
# HTML top-------------------------
print "Content-type:text/html\n\n";
print $amg->header();
if ($view eq 'nsi')
{
print $wf->NameServerInput();
}
else
{
print $wf->SearchForm();
}
# HTML Bottom------------
print $amg->footer();
</code>
Hello,
Looking at the Perl Cookbook: (Recipe 19:12 Writing a Multiscreen CGI Script)
I'm trying to do this:
<code>
%States = (
'Default' => \&front_page,
'Shirt' => \&shirt,
'Sweater' => \&sweater,
'Checkout' => \&checkout,
'Card' => \&credit_card,
'Order' => \&order,
'Cancel' => \&front_page,
);
if ($States{$page}) {
$States{$page}->(); # call the correct subroutine
} else {
no_such_page();
}
</code>
But I can get the following to work. just fine, but 'The Cookbook' calls my method,
"tedious and clumsy". I'm trying to work away from that! ;-)
I'm testing with just two views, but I'll probably end with six or so.
I must admit I only kind of know what I'm doing. I'm sure that's the key to the problem.
I have a feeling I might be making things too complicated. A good hint and a flaming kick
in the pants are very welcomed. TIA - Don
<code>
#!/usr/bin/perl -w
use strict;
use CGI;
use Lib::AccountMgrGeneral;
use Lib::MysqlModule;
use Lib::WebForms;
my $q = new CGI;
my $amg = new AccountMgrGeneral;
my $mysql = new MysqlModule;
my $wf = new WebForms;
my $view = $q->param('view') || 'srch';
# HTML top-------------------------
print "Content-type:text/html\n\n";
print $amg->header();
if ($view eq 'nsi')
{
print $wf->NameServerInput();
}
else
{
print $wf->SearchForm();
}
# HTML Bottom------------
print $amg->footer();
</code>