Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

$text =~ s/R/\r\n/g;
probably not what you wanted, right?

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

$s =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
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.


In reply to Re^3: Top Seven (Bad) Reasons Not To Use Modules by Jenda
in thread Top Seven (Bad) Reasons Not To Use Modules by bellaire

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-18 21:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found