Monks, I am fighting with a nasty little problem of finding out how many levels a HoHoH has for a particular key. I load a Hash with data from a file using Dumper and eval.
*rvd*startScript : /binlib/mdi/rv/etc/start_rvd *rvd*daemonPort : 7500 *rvd*rrcp*sendRate*bufferSize : 1000 chilsd03*rvd*daemonPort : 9000
I need to determine the value of daemonPort and all other variables. If I am running on chilsd03 the value would be 9000 but anywhere else it would be 7500. I refer to this as the scope of the variable being either global or local. I need to scope this further to instance where there can be lines like.
chilsd03*rvd*OUT*daemonPort : 9000
So, the problem I am facing is that I need to figure out a good way to "walk" the hash and load up global and local values but keeping the integrity of the instances. Ideally I need to end up with a hash of
0 'rvd' 1 HASH(0x83d6a40) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 4 'IN' 5 HASH(0x83d6b0c) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 8590 'instanceName' => 'IN' 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 6 'instances' 7 ARRAY(0x83d68f0) 0 'rvd' 1 'IN' What I get instead 0 'rvd' 1 HASH(0x83d6938) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 2 'rrcp' 3 HASH(0x83d8818) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'transmissionBus' => HASH(0x83d87b8) 'driverName' => 'sink,1' 'numBuffers' => 500 'version' => 6.9 4 'OUT' 5 HASH(0x83d6a7c) 'daemonPort' => 9575 'daemonProtocol' => 'tcp' 'httpPort' => 9590 'instanceName' => 'OUT' 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 10 'instances' 11 ARRAY(0x83d67ac) 0 'rvd' 1 'rrcp' 2 'OUT'

In reply to How many levels of indirection in a Hash? by crusty_collins

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.