vlturner has asked for the wisdom of the Perl Monks concerning the following question:
I forgot how to place string text in a variable if a function fails.
my $hostname = gethostbyaddr(inet_aton($data[$ip_address_pos]), AF_INET) or "Can't resolve $data[$ip_address_pos]: $!\n";
Update
OK, fixed it... But have new problem. For some reason PR-Z8K-KC35-0001 kills inet_ntoa() Any ideas???
use Data::Validate::Domain qw(is_hostname); if ( $data[$ip_address_pos] eq "" && $data[$name_pos] ne "" && is_hostname($data[$name_pos])) { my $address = inet_ntoa(inet_aton($data[$name_pos])) || "Error: Can't resolve."; splice @data, ($ip_address_pos), 1, $address; }
Debug data
<c> DB<67> p @data truefalse8falsetruefalse0190c812242e8240298da5114dc38b0d1300577https://staplessb.service-now.com/api/now/table/cmn_location/fd7829030a0a3c0e002edd5fb99dd428fd7829030a0a3c0e002edd5fb99dd428falsehttps://staplessb.service-now.com/api/now/table/sys_user_group/globalglobal4USD0false2015-09-18 23:55:34https://staplessb.service-now.com/api/now/table/cmdb_model/88a82faa89ee2100298df3b18393ef3e88a82faa89ee2100298df3b18393ef3efalsefalsetrueManual Entryfalsetruehttps://staplessb.service-now.com/api/now/table/sys_user_group/14341bae0a0a3c9b019f95720822cb7a14341bae0a0a3c9b019f95720822cb7afalse2015-09-18 23:55:03PR-Z8K-KC35-0001-VOICE - LocalVOICE - Localsales office. We are bringing up the circuit 9/111300577PR-Z8K-KC35-0001PRODtrue2015-09-18 23:55:34CI10333615readyu_cmdb_ci_network_circuit2015-09-11 20:13:550 DB<68> p $data$name_pos PR-Z8K-KC35-0001 DB<69> n Use of uninitialized value in subroutine entry at ServiceNowCMDB_CI_FQDN_Dump.pl line 87. at ServiceNowCMDB_CI_FQDN_Dump.pl line 87. Bad arg length for Socket::inet_ntoa, length is 0, should be 4 at ServiceNowCMDB_CI_FQDN_Dump.pl line 87. at ServiceNowCMDB_CI_FQDN_Dump.pl line 87.
|
|---|