Your input data probably contains an extra \r that is not removed by chomp. You can see that with Data::Dump:
use Data::Dump qw( pp );
# some code here
print pp \@ip;
chomp(@ip);
print pp \@ip;
One of the ways this can happen is when you try to read a file created on Windows with perl running on Linux, or a Cygwin perl.
You can correct that by explicitly setting the input record separator to the CRLF format:
my @ip;
{
local $/ = "\r\n"; # because this is local, the normal behaviour is
+restored after this block
open my $dat, "<", $in_file or die "Can't open file $in_file: $!";
@ip = <$dat>;
chomp(@ip);
close $dat;
}