I'm going insane, right? Trying to trim newlines out of an array read from a file. I'm a relative newb, but everything I've read on the internet tells me this should work. (I've taken out all the format validation for testing).
input.txt has this in it:
Here is my snippet:111.111.111.111 222.222.222.222 333.333.333.333
Output looks like this:my $File = input.txt; open(FILE, "$File"); @IPLIST = <FILE>; close(FILE); foreach my $test (@IPLIST) { print "Is $test an IP?\n"; }
Expected behavior, right? So then I add chomp(@IPLIST); before my loop, and the output becomes this:Is 111.111.111.111 an IP? Is 222.222.222.222 an IP? Is 222.222.222.222 an IP?
Same behavior if I do it on the read: chomp( @IPLIST = <FILE> ); or in the loop for each element. Isn't chomp supposed to do the opposite of this??? What am I missing?Is an IP? Is an IP? Is an IP?
In reply to chomp removes everything *except* the newline? by follier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |