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.


In reply to Forgot variable syntax for $var = funct() or "Funct failed\n" / Any experience with is_hostname() by vlturner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.