I have several instances where I would like to pass a hash (or a hash
reference) in a hidden form field to a subroutine within the same script
upon submitting the form.
So far all my attempts have failed. I'm not even sure if this is
possible. I know about passing named parameters and references but that
only seems to work if the subroutine is called directly, not due to a
form submission. Does anyone know if this is even possible, and if so,
some direction I can take?
#! /usr/bin/perl
BEGIN
{
open (STDERR,">>$0-err.txt");
print STDERR "\n",scalar localtime,"\n";
}
use strict;
use warnings;
use CGI ':standard';
my %Categories =(
1 => "Exterior",
2 => "Interior",
3 => "Audio",
4 => "Vehicles",
5 => "Packages"
);
my $form_url= url();
print "Content-type: text/html\n\n";
my $MODE=param('Mode');
{
no strict;
$MODE="PageOne" unless $MODE; # default sub to execute
&$MODE; # else execute this
}
##############################################
sub PageOne
{
print "<html><body>";
foreach my $k ( sort keys %Categories)
{
print "[$k] => $Categories{$k}<br>";
}
print <<EndHTML;
<form method="post" action="$form_url">
<input type="hidden" name="Categories" value="%Categories">
<input type="hidden" name="Mode" value="ReadCat">
<input type="submit">
</form>
</body>
</html>
EndHTML
}
##################################################
sub ReadCat
{
my %Cats = param('Categories');
print "<html><body>";
foreach my $k (keys %Cats)
{
print "[$k] => $Cats{$k}<br>\n";
}
print "</body></html>\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/