First off, what browser are you using to submit the form? What the browser sends, your script will receive, so it is probably that. Different browsers on different platforms sends different line breaks.
If you are having trouble with replacing two characters, you could for instance strip out all \r characters, either before replacing, or even before you are saving that input to file.
But probably the simplest approach is to do something like this (untested and ugly code):
s/(\r?\n){2}/<p>/g;
s/\r?\n/<br>/g;
That is, replace occurances of an optional
\r and a non-optional
\n with first <p> for double matches, and then <br> for single ones left after the first pass.
Hope that helps.
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.