#!perl use strict; use warnings; my $File = "input.txt"; # this string wasn't quoted, so you must have not shown us the code you're using open(FILE, "<", $File) or die qq(failed to open file "$File": $!); # you didn't check whether open failed chomp(my @IPLIST = ); # this works as expected close(FILE); foreach my $test (@IPLIST) { print "Is $test an IP?\n"; }