in reply to Re^3: Array of Arrays on Monday.
in thread Array of Arrays on Monday.

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

Replies are listed 'Best First'.
Re^5: Array of Arrays on Monday.
by poj (Abbot) on Jan 25, 2016 at 20:17 UTC

    Would this work ?. You may find it easier to build.

    my %application = ( 'CI10335478' => { name => 'app_name1', IP => [ 'MemberIP 1', 'MemberIP 2', 'MemberIP 6', ], }, 'CI10334984' => { name => 'app_name2', IP => [ 'MemberIP 4', 'MemberIP 2', ], }, );
    poj