The first reply seems plausible - I can't imagine any other cause, based on the information you've given so far. When in doubt about line terminations on input, I just do:
s/\s+$//; # instead of chomp
Apart from that, I have to ask: where does your input file come from? How confident are you that it would never contain something that you wouldn't want included in a shell command line?

If you were to add "-T" on the shebang line of your script, it would die rather than do  `host $host`, and with good reason.

Now, if you were to use a module, like Net::DNS::Nslookup (and there may well be others), you could get the IP addresses you want without having to run a shell command in back-ticks for each one. And you wouldn't need to worry about pesky little details like an input file that might contain shell-magic characters in the first column. Instead, your script could look like this:

use strict; use Net::DNS::Nslookup; # ... do whatever you do open FH and load MYDB # (I'll fake it for now...) my %MYDB = ( 'WWW.PERLMONKS.ORG' => 'TPF' ); while (<DATA>) { s/\s+$//; my @hostpair = split ' '; my $HOST = uc( $hostpair[0] ); my $nslookup = Net::DNS::Nslookup->get_ips( $hostpair[0] ); for my $addr ( split( /\n/, $nslookup )) { my ( $name, $ip ) = split( /,/, $addr ); my $OWNER = ( exists( $MYDB{$HOST} )) ? $MYDB{$HOST} : "OTHER" +; print "$hostpair[0]\t$ip\t$OWNER\n"; } } __DATA__ www.perlmonks.org google.com
Maybe that doesn't do exactly what you intended, and maybe you'd rather just use the command-line "host" utility - in that case, do be careful about your input...

In reply to Re: Leading Characters Not Visible for Certain Array Elements While Printing by graff
in thread Leading Characters Not Visible for Certain Array Elements While Printing by justsomeguy

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.