You've got a couple problems here. 1st you can't do what you're looking to do they way you're looking to do it.

When you assign like  $hash{'myhash'}->{ODIR} = %direc; .. there's 2 problems. One, it should be..  $hash->{'myhash'}{ODIR} = ... and second, it's not doing what you think it's doing.

Without giving it away, put this in your script.

print scalar %direc;
That is exactly how the assignment is getting evaluated. It's not assigning the hash itself, it's assigning the results of the hash being evaluated in scalar context.

What I think you want to do is assign a refrence to the hash as in

$hash->{'myhash'}{ODIR} = \%direc;
Now the key ODIR will contain a refrence to the hash %direc. And you'd print it like so..
foreach (sort keys %{$hash->{myhash}{ODIR}}){ print "$_ => $hash->{myhash}{ODIR}{$_}\n"; }
Hope this helps..
Rich

In reply to Re: Referencing to a hash inside a hash of hashes. by rchiav
in thread Referencing to a hash inside a hash of hashes. by JPaul

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.