in reply to File lines being treated as one.

I asked a related question a while ago, and got many helpful replies that are also applicable to your question. Please see Newlines: reading files that were created on other platforms.

In short, I chose to preprocess the input file to convert all newline characters to the current system's newline character:

$file =~ s[(\015)?\012(?!\015)][\n]g; $file =~ s[(\012)?\015(?!\012)][\n]g;

HTH