I need Hash of Hashes.... But here,s the rub. All these lines are CI records from a ServiceNow CMDB. So I screwed up thinking the application name was on the same line. The application name is only the CI ( CI10335478 ). Now I need to look up the name of the CI and all applications have a sys_class_name = "cmdb_ci_appl" Its just that I need a placeholder for Application Name because the line containing that may be 10000 lines or more down the data. But I need a place holder for application name until it comes along and we can populate it. This is because the ouput data need to look like this.

Status,Name,Description,Members,Id,InboundUtilizationBandwidth,Outboun +dUtilizationBandwidth,Appliances,CollectOnDirector ,app_name1,CI10335478,MemberIP1;MemberIP2;MemberIP6,,,,, ,app_name2,CI10334984,MemberIP4;MemberIP2,,,,,

So what I need is to buld out the following array.

$VAR1 = { 'CI10335478' => 'app_name1' => MemberIP 1, MemberIP 2, MemberIP 6 ], 'CI10334984' => 'app_name2' => MemberIP 4, MemberIP 2, }; our %application = (); sub add_to_application_members { my ($app_ci, $member_ip, $value) = @_; $application{$app_ci{$member_ip}} = $value; } sub add_to_application_names { my ($member, $value) = @_; $application{$member} = $value; } if ( $data[$class_pos] eq "cmdb_ci_appl" ) { add_to_application_names( $data[$ci_pos] => $data[$name_pos] ); print Dumper( %application ) ; } if ( $data[$application_pos] ne "" && $data[$ip_address_pos] ne "" ) { add_to_application_members( $data[$application_pos] => $data[$ip_add +ress_pos] ); print Dumper( %application ) ; } _DATA_ u_ci_id,sys_class_name,application,ip_address ,name CI12345,cmdb_ci_appl , , ,foobar1 CI56789,cmdb_ci_svr ,CI12345 ,10.10.10.10, hostname1

In reply to Re^4: Array of Arrays on Monday. by vlturner
in thread Array of Arrays on Monday. by vlturner

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.