Ok, I looked up some documentation and found something that might work.  The
only problem is I'm unfamiliar with the particular task that is described in
the docs.  Here is what it says in the docs...
---------
A totally different approach is to create a hash of function
references.

    my %commands = (
        "happy" => \&joy,
        "sad",  => \&sullen,
        "done"  => sub { die "See ya!" },
        "mad"   => \&angry,
    );

    print "How are you? ";
    chomp($string = <STDIN>);
    if ($commands{$string}) {
        $commands{$string}->();
    } else {
        print "No such command: $string\n";
    }
---------

I think this would be the best method for me because I have a bunch of
subroutines that I would like to reference in my hash.  I run into a problem
when I try to insert some arguments into the hash that need to be sent to my
subroutines.  I have some variable arguments that aren't defined yet but
will be when the command is executed in the if statement toward the bottom
of the code.

Am I missing something here?

Here is some of my code....I have a web page that gets output if there is no
state variable submitted otherwise the apropriate state defines the
subroutine call.

-----------
my %commands = (
    "ItemsEnteredThisWeek" => \&RecentlyEnteredItems(\$dbh,"ThisWeek"),
    "ItemsEnteredThisMonth",  => \&RecentlyEnteredItems(\$dbh,"ThisMonth"),
    "ECOLookup"  => \&ECOLookup(\$dbh,\$FormData{"input"})
);
if ($commands{$FormData{"state"}}) {
        my $dbh = DBI->connect("dbi:ODBC:--server--", "--username---",
"--password--", {
                PrintError => 0,
                RaiseError => 1} )
                or die "Can't connect to ODBC database: $DBI::errstr\n";
        $commands{$FormData{"state"}}->();
        $dbh->disconnect();
} else {
        print '<html><h1>Kevs - Online Reports</h1><br>';
        print '<font size=4>This application takes input and extracts the
specified report';
        print ' from the business system and displays the results in your
web browser.</font><p>';
        print '<form name="Webflo" action="../cgi-bin/kevsflo.pl"
method="post">'."\n";
        print '<table><tr><th>Report Type</th><th>Input</th></tr>';
        print '<tr><td>'."\n";
        print '<select name="state"><option
value="RecentlyEnteredItems">Recently Entered Item Numbers</option>'."\n";
        print '<option value="ECOLookup">Engineering Change by
OCN</option></select></td><td>'."\n";
        print '<input type="text" name="input" size="20" value=""
maxlength="20"></td></tr></table>';
        print '<input type="submit" name="submitButtonName">'."\n";
        print '</form>'."\n";
        print '<br><b>Please note that if you get no report displayed after
submitting a request';
        print ' it probably means that you entered an invalid part
number.</b><br>';
        print '</html>';
}
-----------

Thanks for any help

Kevin Ailes
Administrator
OTTO Engineering
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to