I ran into a similar problem a while ago. See the great replies I got in Newlines: reading files that were created on other platforms. In short, the options include using regexen to convert the newline characters, binmode, or File::LocalizeNewlines.

In reply to Re: Can't get rid of \r by bobf
in thread Can't get rid of \r by rovf

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":