Macs formerly used CR (\x0D) as the line separator. Perl for the older Macs responded by redefining \n as CR (\x0D) and leaving the input record separator ($/) as \n.
Newer Macs use LF (\x0A) as the line separator like other unix platforms. Perl builds for modern Macs should leave \n as LF (\x0A).
I believe your Word is using the old standard (using CR as the input record separator) and your Perl is expecting LF. TextEdit silently(?) converts the line endings. You can do so programmatically using the following tool:
#!/usr/bin/perl
#
# Converts LF, CR and CRLF line endings to the local line ending.
#
# Usage:
# fix_line_endings infile > outfile
# fix_line_endings < infile > outfile
# perl -i.bak fix_line_endings file (In place)
#
use strict;
use warnings;
my $file = do { local $/; <> };
$file =~ s/\x0A|\x0D\x0A?/\n/g;
print $file;
Update: Simplified code. |