It looks to me like your problem is that you arent using strict.

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.

my %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
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. Thus
$new{foo}{baz}='new'; print $hash{foo}{baz},"\n"; #prints new
Taking a deep copy is more complicated, and I wont address it unless you follow up saying that you need to do so.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.