You're viewing a comment by Dave Cross and its responses.

February 12, 2010, 16:18

The whole area of line endings is a lot more complex than this article implies. The \n character represents whatever is the end-of-line character on your current system. Therefore when running on Windows, \n actually represents a sequence of two characters - a carriage return character (x0D) followed by a line feed character (x0A).

For this reason, best practice is to use real character codes rather than escape characters. I recommend:

s/\015\012/\012/ # Windows -> Unix
s/\012/\015\012/ # Unix -> Windows

See the section on newlines in "perldoc perlport" for more details.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.