Hello everyone:
I am trying to pass a hash of hashes from one script to another via a
cookie. I can get the cookie to pass, but when I try to get the inner
hash keys and values using what I think is the correct method, I
cannot get them. Here are two scripts which should do it, but don't:
#1: pretest.cgi
#!/usr/bin/perl -wT
use CGI ':standard';
my $xx = new CGI;
%KK = (a=>"A",b=>"B");
open (SCRATCH,">/tmp/scratch") or die "Couldn't open scratch for
writing: $!\n";
chmod 0755,"tmp/scratch";
print SCRATCH "In pretest.cgi.\n";
for (keys %{KK}) {
print SCRATCH "Key: ",$_,"\t",
"Value from reference: ",${KK}{$_},"\n";
}
print SCRATCH "\n\n";
my $kk=\%KK;
print $xx->redirect(-COOKIE=>$kk,-URL=>"test.cgi");
#2 test.cgi:
#!/usr/bin/perl -wT
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use diagnostics;
$xx = new CGI;
%cookhash=cookie('bigcook');
$KK=$cookhash{'KK'};
open (SCRATCH,">>/tmp/scratch") or die "Couldn't open scratch for
appending: $!\n";
chmod 0775,"tmp/scratch";
print $xx->header;
print $xx->start_html(-title=>"test",-bgcolor=>"silver",-
vlink=>"blue"),
$xx->hr, $xx->p,$xx->br;
print $xx->center( $xx->h2("In test.cgi!\n") );
print $xx->center( $xx->h2("\$KK is $KK\n") );
print SCRATCH "In test.cgi!\n";
print SCRATCH "\$KK is $KK\n";
for (keys %{$KK}) {
print SCRATCH "Key: ",$_,"\t";
print SCRATCH "Value from reference: ",${$KK}{$_},"\n";
}
for (keys %{$KK}) {
print $xx->center($xx->h2("Key: ",$_,"\n"),
$xx->h2("value from reference: ",${$KK}{$_},"\n"));
}
print $xx->end_html;
As you can see if you run these two scripts, the dereferencing step
didn't give me back my hash %KK. I used the same synax to dereference
$KK in both programs, but it didn't work for the passed one. Can
anybody help? Thanks in advance.
Mike
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/