in reply to Re^2: Top Seven (Bad) Reasons Not To Use Modules
in thread Top Seven (Bad) Reasons Not To Use Modules
Erm ... what do you expect the \R to mean? I don't know, maybe it means something in Perl 5.10, but in 5.8 it's equivalent to R. So what you wrote was equivalent to
probably not what you wanted, right?$text =~ s/R/\r\n/g;
Even though this is not a task that would be too complex, it's not such a no-brainer as you seem to imply. It's not really "convert the internal notion of newlines (\n) to the Windows notion (CR LF)". It's "convert whatever newlines to the Windows newlines". So it should handle not only "\n", but also "\r\n" (windows already) and "\r" (old Mac). You do not want to end up with "CR CR LF", do you?
I use
within Mail::Sender, but if I did not want to waste my time and wanted to be sure I end up with the right line ends without having to study all posibilities, Text::FixEOL looks like a very good candidate.$s =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Top Seven (Bad) Reasons Not To Use Modules
by dreadpiratepeter (Priest) on Mar 13, 2009 at 17:28 UTC | |
Re^4: Top Seven (Bad) Reasons Not To Use Modules
by JavaFan (Canon) on Mar 13, 2009 at 15:38 UTC | |
by Lawliet (Curate) on Mar 13, 2009 at 18:59 UTC | |
by JavaFan (Canon) on Mar 14, 2009 at 00:37 UTC |
In Section
Meditations