You probably want to use "\015\012" for CR/LF since the values of \r and \n vary from system to system
Bleh. I prefer to not let the mistakes of a single platform sway me away from previous good practices in writing portable code. The only platform where "\r" and "\n" caused any concern was old Macs. There are a lot more non-ASCII platforms where hard-coding magic numbers would cause problems. Granted, there was a period where running into what is now an "old" Mac Perl was much, much more likely than running into a non-ASCII Perl (at least for most people). It is a bit sad, however, that this visibility caused so many people to just overlook the long-standing realization that hard-coded magic numbers are a bad practice, including enshrining the encouragement of such bad practices in perlport (and some people who are still convinced that these hard-coded magic numbers are actually a "good practice").
But I've never run into an old Mac Perl and I strongly object to hard-coding such magic numbers so I find "\r" and "\n" much preferable. When writing code for public consumption, I might provide an abstraction that specifically detects old Macs. But the complexity of such an abstraction just isn't justified for me most of the time.
- tye
In reply to Re^2: question about "split" function (magic numbers)
by tye
in thread question about "split" function
by rimvydazas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |