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

poj is on the right track, and for some reason, I got myself confused and am stuck now. So he sent this.

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

I have 250K records in XML that are parsing correctly. So now I need to get them into the hash. $data$name_pos contains the application name on application CI's. $data$application_pos contains the CI of the application we need to look up $data$name_pos on device CI's So $application_pos and $data$ci_pos should be equal. I have to process > 5K of records to start getting intersections of the data, and I don't want to put that here, and its all in XML. So my idea was to write my data to the hash or array when I come across them. So I don't have a blob to just push into the structure.

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

    Use a separate hash for the names and combine them with IPs at the end

    #!perl use strict; use Data::Dump 'pp'; my %tmp =(); my %name=(); my $header = <DATA>; while(<DATA>){ chomp; my ($u_ci,$class,$app,$ip,$name) = split ',',$_; if ($class eq 'cmdb_ci_appl'){ $name{$u_ci} = $name; } elsif ($class eq 'cmdb_ci_svr'){ $tmp{$app}{$ip}=1; } else { print "$class\n"; } } my %application = (); for my $app (keys %tmp){ $application{$app}{'IP'} = [sort keys %{$tmp{$app}}]; $application{$app}{'name'} = $name{$app}; } pp \%application ; __DATA__ u_ci_id,sys_class_name,application,ip_address ,name CI56789,cmdb_ci_svr,CI10335478,MemberIP 1,hostname1 CI56789,cmdb_ci_svr,CI10335478,MemberIP 2,hostname1 CI56789,cmdb_ci_svr,CI10335478,MemberIP 6,hostname1 CI56789,cmdb_ci_svr,CI10334984,MemberIP 4,hostname1 CI56789,cmdb_ci_svr,CI10334984,MemberIP 2,hostname1 CI10334984,cmdb_ci_appl,,,app_name2 CI10335478,cmdb_ci_appl,,,app_name1
    poj