SPUG: Reference to a hash

Martin, Asa asa.martin at attws.com
Thu Mar 21 19:41:49 CST 2002

I have a data structure, Hash of Hashes. Most of the entries are single
values. Some are however other hashes. I use $key as a numeric number
incremented for each hash with each key having different headings. For

$HoH{$key}{$heading1} = $value1; 
$HoH{$key}{$heading2} = $value2;

For the times when $value is not a scalar, I populate a hash of values. I
then tried to associate that hash as a value like so:

$HoH{$key}{$heading} = \%hash;

For some reason this did not work. When I went to access it as
%{HoH{$key}{$heading}} it did not contain the original data but was empty.
So I had to do this to populate it.

for (keys %hash) {
    $HoH{$key}{$heading}{$_} = $hash{$_};

Any ideas as to what's going on here? I'm sure I'm missing something obvious
(certainly wouldn't be the first time). 


Asa C Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20020321/65b27ee3/attachment.htm

More information about the spug-list mailing list