There's more than one way to do things | |
PerlMonks |
Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...by blm (Hermit) |
on Sep 16, 2002 at 11:33 UTC ( [id://198216]=note: print w/replies, xml ) | Need Help?? |
Beat me to but I am not as revered as Aristotle. The only way I knew is that I got caught out badly reading dos text files on linux. Everyone that uses perl on different platforms, be they Mac, *nix and/or Windows/DOS based, should read perlport for the low down on when \n is \012 or \015 or \015\012 .To quote some words of wisdom: In most operating systems, lines in files are terminated with newlines. Just what is used as a newline may vary from OS to OS. Unix traditionally uses \012, one kind of Windows I/O uses \015\012, and Mac OS uses \015. Perl uses \n to represent the ``logical'' newline, where what is logical may depend on the platform in use. In MacPerl, \n always means \015. In DOSish perls, \n usually means \012, but when accessing a file in ``text'' mode, STDIO translates it to (or from) \015\012. Amen ;-)
In Section
Seekers of Perl Wisdom
|
|