Perl uses \n (the linefeed) as its default end of line character (record separator). You can change this with -0
option on the command line to be \r (carriage return), \r\n (carriage return linefeed pair) or something else. For example, this command sets the record separator to \r before replacing every occurence of the string foo with the string bar:
$ perl –pi -e -00d ‘s/foo/bar/g’ test.html
However my files are a weird mix of Unix, Mac, and Windows conventions. A few files may even use several line ending conventions in one file. Most modern text editors can autodetect and deal with this without any problem, as can XML parsers. However as near as I can figure, Perl cannot. It expects me to know in advance what kind of file I’m feeding it.
Is there any simple way around this? There’s more than one way to do it, but is there more than one $/
?