The reason I say this is that the hash that $framearray->{$frameno}{$drawerno} refers to isnt %framearray, but rather an anonymous hash contained referenced by $framearray
So you have two solutions, change the offending call to $framearray{$frameno}{$drawerno}="foo"; _or_ change the %newhash=%framearray to be %newhash=%$framearray
But as I said this type of error would be instantly indentified by turning on strict.
BTW, you should realize that %x=%y will only do a shallow copy on nested HOH's. In otherword the subhash in $hash{foo} and in $new{foo} will be the same. Thusmy %hash; $hash{foo}{bar}="baz"; my %new=%hash; print $new{foo}{bar},"\n"; #prints baz my $hashref; $hashref->{foo}{bar}='ref'; my %new2=%$hashref; print $new2{foo}{bar},"\n"; #prints baz
Taking a deep copy is more complicated, and I wont address it unless you follow up saying that you need to do so.$new{foo}{baz}='new'; print $hash{foo}{baz},"\n"; #prints new
HTH
--- demerphq
my friends call me, usually because I'm late....
In reply to Re: Copying a hash to another hash problem
by demerphq
in thread Copying a hash to another hash problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |