This is what data::dumper prints out. I want to be able to iterate over this. So for example if $VAR2 = 'dev', then read 'nfsmount' and then depending on whether the next level down equals 'bigstor_nfs'/'mbig_nfs'/'build_nfs'/'cc_nfs'/'home_nfs' I want to then be able to iterate over those individual hashes and extract particular key/value pairs and output to another file:
$VAR1 = 'tag'; $VAR2 = { 'dev' => [ { 'nfsmount' => { 'bigstor_nfs' => { 'bigstor17_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volC' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volC/bigstor17 +', + 'nj_loc' => '/vol/bigstor_volC/bigstor17 +' + }, + 'export_name' => '/bb/bigstor17' + },
'bigstor14_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor14 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor14 +' + }, + 'export_name' => '/bb/bigstor14' + }, 'bigstorq3_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap3289-s', + 'nj_loc' => 'nydevnfs_bigstorq3' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorq3', + 'nj_loc' => '/vol/bigstorq3' + }, + 'export_name' => '/bb/bigstorq3' + }, 'bigstor12_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor12 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor12 +' + }, + 'export_name' => '/bb/bigstor12' + }, 'bigstor13_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor13 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor13 +' + }, + 'export_name' => '/bb/bigstor13' + }, 'bigstor15_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor15 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor15 +' + }, + 'export_name' => '/bb/bigstor15' }, 'bigstor3_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor3', + 'nj_loc' => '/vol/bigstor_volA/bigstor3' + }, + 'export_name' => '/bb/bigstor3' + }, 'bigstor4_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor4', + 'nj_loc' => '/vol/bigstor_volA/bigstor4' + }, + 'export_name' => '/bb/bigstor4' + }, 'bigstor19_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volC' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volC/bigstor19 +', + 'nj_loc' => '/vol/bigstor_volC/bigstor19 +' + }, + 'export_name' => '/bb/bigstor19' + }, 'bigstor18_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volC' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volC/bigstor18 +', + 'nj_loc' => '/vol/bigstor_volC/bigstor18 +' + }, + 'export_name' => '/bb/bigstor18' + }, 'default' => + { + 'group' => 'root', + 'acl' => '0755', + 'user' => 'root', + 'opts' => 'nfsvers=3,timeo=600,retrans=2' + }, 'bigstorq4_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap3290-s', + 'nj_loc' => 'nydevnfs_bigstorq0' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorq4', + 'nj_loc' => '/vol/bigstorq4' + }, + 'export_name' => '/bb/bigstorq4' + }, 'bigstorderv +_mpt' => { + 'filer_device' => { 'ny_loc' => 'nyde +vnfs_derv', + 'nj_loc' => 'nydevnfs_derv' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mtge', + 'nj_loc' => '/vol/mtge' + }, + 'export_name' => '/bb/bigstor/derv' + }, 'bigstor23_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volD' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volD/bigstor23 +', + 'nj_loc' => '/vol/bigstor_volD/bigstor23 +' + }, + 'export_name' => '/bb/bigstor23' + }, 'bigstor1_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor1', + 'nj_loc' => '/vol/bigstor_volA/bigstor1' + }, + 'export_name' => '/bb/bigstor1' + }, 'bigstor5_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor5', + 'nj_loc' => '/vol/bigstor_volA/bigstor5' + }, + 'export_name' => '/bb/bigstor5' + }, 'bigstor30_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor30 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor30 +' + }, + 'export_name' => '/bb/bigstor30' + }, 'bigstor8_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor8', + 'nj_loc' => '/vol/bigstor_volA/bigstor8' + }, + 'export_name' => '/bb/bigstor8' + }, 'bigstorq1_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstorq1', + 'nj_loc' => 'nydevnfs_bigstorq1' }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorq1', + 'nj_loc' => '/vol/bigstorq1' + }, + 'export_name' => '/bb/bigstorq1' + }, 'bigstor10_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor10 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor10 +' + }, + 'export_name' => '/bb/bigstor10' + }, 'bigstorqird +_mpt' => { + 'filer_device' => { + 'ny_loc' => 'nnap3290-s', + 'nj_loc' => 'nydevnfs_bigstor_ird' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_ird', + 'nj_loc' => '/vol/bigstor_ird' + }, + 'export_name' => '/bb/bigstor_ird' + }, 'bigstorq2_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstorq2', + 'nj_loc' => 'nydevnfs_bigstorq2' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorq2', + 'nj_loc' => '/vol/bigstorq2' + }, + 'export_name' => '/bb/bigstorq2' + }, 'bigstor11_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor11 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor11 +' + }, + 'export_name' => '/bb/bigstor11' + }, 'bigstorq0_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstorq0', + 'nj_loc' => 'nydevnfs_bigstorq0' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorq0', + 'nj_loc' => '/vol/bigstorq0' + }, + 'export_name' => '/bb/bigstorq0' + }, 'bigstor29_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor29 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor29 +' + }, + 'export_name' => '/bb/bigstor29' + }, 'bigstor7_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor7', + 'nj_loc' => '/vol/bigstor_volA/bigstor7' }, + 'export_name' => '/bb/bigstor7' + }, 'bigstor20_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volC' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volC/bigstor20 +', + 'nj_loc' => '/vol/bigstor_volC/bigstor20 +' + }, + 'export_name' => '/bb/bigstor20' + }, 'bigstor16_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volB' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volB/bigstor16 +', + 'nj_loc' => '/vol/bigstor_volB/bigstor16 +' + }, + 'export_name' => '/bb/bigstor16' + }, 'bigstor21_m +pt' => { + 'filer_device' => { + 'ny_loc' => 'nnap5307-s', + 'nj_loc' => 'nydevnfs_bigstor_volC' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volC/bigstor21 +', + 'nj_loc' => '/vol/bigstor_volC/bigstor21 +' + }, + 'export_name' => '/bb/bigstor21' + }, 'bigstorsas_ +mpt' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_sas', + 'nj_loc' => 'nydevnfs_sas' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/sas', + 'nj_loc' => '/vol/sas' + }, + 'export_name' => '/bb/bigstor/sas' + }, 'bigstor2_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => 'nydevnfs_bigstor_volA' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/bigstor2', + 'nj_loc' => '/vol/bigstor_volA/bigstor2' + }, + 'export_name' => '/bb/bigstor2' + }, 'bigstorn_mp +t' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstorn', + 'nj_loc' => 'nydevnfs_bigstorn' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstorn', + 'nj_loc' => '/vol/bigstorn' + }, + 'export_name' => '/bb/bigstorn' + }, 'bigstormtg_ +mpt' => { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_mtge', + 'nj_loc' => 'njdevnfs_mtge' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mtge', + 'nj_loc' => '/vol/mtge' }, + 'export_name' => '/bb/bigstor/mtgmodel' + } }, 'mbig_nfs' => { 'mbiga_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap7697-s', + 'nj_loc' => 'nydevnfs_mbiga' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbiga', + 'nj_loc' => '/vol/mbiga' + }, + 'export_name' => '/bb/mbiga' +}, 'mbigb_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap7698-s', + 'nj_loc' => 'nydevnfs_mbigb' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbigb', + 'nj_loc' => '/vol/mbigb' + }, + 'export_name' => '/bb/mbigb' +}, 'mbig14_mpt' => + { + 'filer_device' => { + 'ny_loc' => 'nnap5479-s', + 'nj_loc' => 'rnap7751-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbig9', + 'nj_loc' => '/vol/mbig9_c' + }, + 'export_name' => '/bb/mbig14' + }, 'mbigd_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap9413-s', + 'nj_loc' => 'nydevnfs_mbigd' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbigd', + 'nj_loc' => '/vol/mbigd' + }, + 'export_name' => '/bb/mbigd' +}, 'default' => { +'group' => 'root', +'acl' => '0755', +'user' => 'root', +'opts' => 'nfsvers=3,timeo=600,retrans=2' }, 'mbig10_mpt' => + { + 'filer_device' => { + 'ny_loc' => 'nnap5166-s', + 'nj_loc' => 'rnap2114-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbig4', + 'nj_loc' => '/vol/mbig4_c' + }, + 'export_name' => '/bb/mbig10' + }, 'mbig6_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap4211-s', + 'nj_loc' => 'rnap7751-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbig6', + 'nj_loc' => '/vol/mbig6_c' + }, + 'export_name' => '/bb/mbig6' +}, 'mbig13_mpt' => + { + 'filer_device' => { + 'ny_loc' => 'nnap5478-s', 'nj_loc' => 'rnap7750 +-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbig8', + 'nj_loc' => '/vol/mbig8_c' + }, + 'export_name' => '/bb/mbig13' + }, 'mbigt_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap4210-s', + 'nj_loc' => 'nydevnfs_mbigt' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbigt', + 'nj_loc' => '/vol/mbigt' + }, + 'export_name' => '/bb/mbigt' +}, 'mbig7_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap5165-s', + 'nj_loc' => 'rnap2113-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbig1', + 'nj_loc' => '/vol/mbig1_c' + }, + 'export_name' => '/bb/mbig7' +}, 'mbigc_mpt' => +{ + 'filer_device' => { + 'ny_loc' => 'nnap9412-s', + 'nj_loc' => 'nydevnfs_mbigc' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/mbigc', + 'nj_loc' => '/vol/mbigc' + }, + 'export_name' => '/bb/mbigc' +}, 'mbigold_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_bigstor_volA', + 'nj_loc' => undef + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bigstor_volA/mbig', + 'nj_loc' => undef + }, + 'export_name' => '/mbigold' + } }, 'build_nfs' => { 'build7_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nnap5478-s', + 'nj_loc' => 'rnap7750-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/source4', + 'nj_loc' => '/vol/source4_c' + }, + 'export_name' => '/bbsrc4' + }, 'build17_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nnap5479-s', + 'nj_loc' => 'rnap7751-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/cstools', + 'nj_loc' => '/vol/cstools_c' + }, + 'export_name' => '/bb/cstools' + }, 'build20_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nnap4210-s', + 'nj_loc' => 'nydevnfs_bbcm' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bbcm', + 'nj_loc' => '/vol/bbcm' }, + 'export_name' => '/bb/bbcm' + }, 'build9_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nnap5166-s', + 'nj_loc' => 'rnap2114-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bbshr', + 'nj_loc' => '/vol/bbshr_c' + }, + 'export_name' => '/bbshr' + }, 'build4_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nnap5166-s', + 'nj_loc' => 'rnap2114-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/source', + 'nj_loc' => '/vol/source_c' + }, + 'export_name' => '/bbsrc' + }, 'build19_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nydevnfs_robostor', + 'nj_loc' => 'nydevnfs_robostor' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/robostor', + 'nj_loc' => '/vol/robostor' + }, + 'export_name' => '/bb/robostor' + }, 'build3_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nnap5478-s', + 'nj_loc' => 'rnap7750-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/bbsrc_cg', + 'nj_loc' => '/vol/bbsrc_cg_c' + }, + 'export_name' => '/bbsrc_cg' + }, 'build6_mpt' = +> { + 'filer_device' => { + 'ny_loc' => 'nnap4211-s', + 'nj_loc' => 'rnap7751-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/source3', + 'nj_loc' => '/vol/source3_c' + }, + 'export_name' => '/bbsrc3' + }, 'build22_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nnap4211-s', + 'nj_loc' => 'rnap7751-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/csdk', + 'nj_loc' => '/vol/csdk_c' + }, + 'export_name' => '/bb/client_sdk' + }, 'build11_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nnap7698-s', + 'nj_loc' => 'nydevnfs_princetonsrc' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/princetonsrc', + 'nj_loc' => '/vol/princetonsrc' + }, 'export_name' => '/bb/princeton +' + }, 'build24_mpt' +=> { + 'filer_device' => { + 'ny_loc' => 'nnap5165-s', + 'nj_loc' => 'rnap2113-s' + }, + 'filer_volume' => { + 'ny_loc' => '/vol/offlines1', + 'nj_loc' => '/vol/offlines1_c' + }, + 'export_name' => '/bb/offlines' + }, ...

In reply to Re^2: Iterate over a perl nested hash data structure by NewLondonPerl1
in thread Iterate over a perl nested hash data structure by NewLondonPerl1

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.