Hello,

I have a three dimensional hash with info like below.

%LPAR_config = ( 'lpar1' => { 'profile1' => { ... }, 'profile2' => { ... }, 'frame' => 'frame1', 'lpar_id' => '1' } 'lpar2' => { 'profile1' => { ... }, 'profile2' => { ... }, 'frame' => 'frame1', 'lpar_id' => '2' 'lpar3' => { 'profile1' => { ... }, 'profile2' => { ... }, 'frame' => 'frame2', 'lpar_id' => '1' } 'lpar4' => { 'profile1' => { ... }, 'profile2' => { ... }, 'frame' => 'frame2', 'lpar_id' => '2' ... )

I've skipped the original list, as it has 191 lpars and each a lot of info. At one point in the program I need to get the name of the lpar from frame2 with lpar_id 1.

I'm now looping trough the keys to check if the lpar with name $key is on frame "frame2" and has lpar_id 1.
As I can skip most of the entries I was wondering, is there an easier way to get the key based on the content of the values of $key

On a related note, is there an easy way (read without looping myself) to copy a subset of the hash (for example all lpars on frame2) to another hash? This would speed-up the script, as most data is needed of just 1 frame (of 14 available)


In reply to Easy way to find data in hash or get subset of hash by T_I

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.