Apologies if this is going over old ground, but I can't find the answer to this in the archives.

I'm trying to dynamically build a hash of hashes, but I can't seem to get the context right. Here's the test code I'm working on:
my %attrs = ( name => 'Band', link => 'band.html'); print "ATTRS KEYS = ", keys %attrs, "\n"; print "ATTRS VALUES = ", values %attrs, "\n"; my %container = (); $container{ATTRIBUTES} = %attrs; print "CONTAINER KEYS = ", keys %container, "\n"; print "CONTAINER VALUES = ", values %container, "\n"; my %new_attrs = $container{ATTRIBUTES}; print "NEW_ATTRS KEYS = ", keys %new_attrs, "\n"; print "NEW_ATTRS VALUES = ", values %new_attrs, "\n";
What I want is for the %new_attrs hash to be loaded with the hash that I put into %container, but it only wants to give me a garbage reference. If I try the line like this:
my %new_attrs = %{$container{ATTRIBUTES}};
... I get nothing out at the end (other than a Can't use string ("1/8") as a HASH ref while "strict refs" error if strict is in use).

Any help would be much appreciated.

willdooUK
--------------
"Home is a castle you built in my mind; I'm home anywhere, anytime."
Donny Hathaway

In reply to Dynamically building a hash of hashes by willdooUK

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.