in reply to Re^5: Need help with complex hash of hashes.
in thread Need help with complex hash of hashes.
OK, I figured out how the record subroutine was blowing up inside the Twig module. It was the "next if" line that hung it.
So I had to change it to this, seems I am ending up with CI's with members but no name. I am working to resolve that.if ( $class eq 'cmdb_ci_svr' ){ next if $seen{$app}{$ip}++; push @{$arx_data{$app}{'members'}},$ip; }
if ( $class eq 'cmdb_ci_appl'){ push @{$arx_data{$u_ci}{'name'}}, $name; } elsif ( $app ne "" && $ip ) { if ( exists $arx_data{$u_ci}{'name'} ) { push @{$arx_data{$app}{'members'}},$ip; } else { push @{$arx_data{$u_ci}{'name'}}, $null; push @{$arx_data{$app}{'members'}},$ip; } }
Now what I want to add is one of the sections that cleans up the data first. This validates the IP address and the name that should be its hostname from DNS records. Now I am trying to add this to your codebase which uses $ip instead of $data$ip_address_pos, but I was using the positional value to splice the corrected data. This is to create the CSV file with the corrected data, and I will also use it to fix ip addresses in the member arrays too. Any suggestion?
if ( $data[$ip_address_pos] eq "" && $data[$name_pos] ne "" && is_hostname($data[$name_pos])) { my $address = inet_aton($data[$name_pos]) || "Error: Can't resolve."; if ( $address ne "" && $address ne "Error: Can't resolve." ) { $address = inet_ntoa($address); splice @data, ($ip_address_pos), 1, $address; my $cmdb_name = $data[$name_pos]; my $cmdb_lc_name = lc $cmdb_name; splice @data, ($name_pos), 1, $cmdb_lc_name; } }
|
|---|