Hi Y'all. Bless me.. For it has been years since my last post on a forum like this.

I could not think of a way to search this or any other forum/search engine for a question like this.

I have a configuration file that contains fields that are actually the of "fields" in a hash. (Actually a json hash but that's besides the issue at hand.) These will correspond with positional parameters supplied at run-time. For example, here re a couple of lines; each is a set of fields, comma separated:

name,address-virtual-email movie-role,hoig-boig-loig-shmoig
(I do need to protect the private data of my client.)

The first line requires that I plunk a value into:

o $js->{name} # This is the easy part o $js->{address}{virtual}{email} # Here's the trouble
The second line tells to plunk run-time values into
o $js->{movie}{role} # In this example o $js->{hoig}{boig}{loig}{shmoig} # both are trouble!
There are dozens of such lines in the config file and there's no telling what they will add to the list. So I'm racking my brains out for a way to address the substructures (using the term loosely) in a dynamic fashion. I can certainly combine the string $compound = "{hoig}{boig}{loig}{shmoig}" but it won't help me to address js=>{$compound} because that is just a string and there is no such key in the hash.

Can anyone come up with a way to get at the nested fields in the hash when I can't know in advance which keys (and sub-keys) I will need to address? I don't believe the symbol table will help here; the keys of the hash (and all its sub-hashes) are not in the symbol table (I think).

Thanks! Gracias! Spasiba! Szepem Köszönöm!

-- RP


In reply to Dynamic addressing in a hash by rpaskudniak

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.