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;
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",-
$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.


Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupbeginners @
postedJan 18, '10 at 7:11p
activeJan 20, '10 at 1:17a



site design / logo © 2021 Grokbase