in reply to Unix \n vs. DOS \n

You probably forgot to use "binmode" built-in function, which makes sence for text-mode or binary-mode.

Otherwise, if you're inside perl script, then perl makes UNIX-like line endings, for example in HERE-IN strings and inside any strings:

$a=<<"EOS"; abcd efgh EOS
and
$a="abcd efgh ";
and
$a="abcd\nefgh\n";
are the same.