T_I has asked for the wisdom of the Perl Monks concerning the following question:
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Easy way to find data in hash or get subset of hash
by roboticus (Chancellor) on Mar 05, 2013 at 15:42 UTC | |
|
Re: Easy way to find data in hash or get subset of hash
by Athanasius (Archbishop) on Mar 05, 2013 at 15:49 UTC | |
by T_I (Novice) on Mar 05, 2013 at 16:02 UTC | |
|
Re: Easy way to find data in hash or get subset of hash
by Anonymous Monk on Mar 05, 2013 at 15:33 UTC |