Use a separate hash for the names and combine them with IPs at the end
poj#!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
In reply to Re^5: Array of Arrays on Monday.
by poj
in thread Array of Arrays on Monday.
by vlturner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |