As others have explained, the basic issue is to remove the carriage-return characters (a.k.a. "\r", "\x0d", "\015" and the keycode emitted by 'ctrl-M') which Windows puts in front of every line-feed character.
Of course, a Windows plain-text file with the carriage-returns still present is also "compatible" with UNIX, for a fairly wide range of activities where the presence of carriage-returns makes no difference to the user or the application.
In the context of applications written in Perl, whenever I write Perl for a task where the range of inputs might include Windows text files as well as linux/unix text data, and where the nature of the line termination might be an issue, I just use the following instead of chomp:
That way, the script will behave consistently on both Windows and linux/unix systems, regardless whether the data is coming from the same system or a different system.s/[\r\n]+$//;
In reply to Re: Unix vs Windows Text File Format
by graff
in thread Unix vs Windows Text File Format
by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |