If the input file was generated on a different platform (one that uses a different EOL sequence), chomp might not strip off all the newline characters. For example, if you created the text file in Windows (which uses \r\n
) and ran the script on Mac or Linux, only the \n
would get chomp()
ed and the output would still "look" like it had newlines.
If you know what the EOL sequence of the input is, you can set $/
before chomp()
. Otherwise, you may need to do something like
my @emails = map { s/[\n\r]+$//g; $_ } <INPUT>;