Lots of people giving you variations on the theme of how to make the changes you asked for, but no-one stepping back and asking what you're trying to achieve.

Changing newlines to <br> tags is a display issue. You should only be making changes like this to a copy of the data that it being displayed to the user in a browser. If you're storing the data somewhere for processing later then you should store it in its original format.

As an example of why this approach it useful consider the change from HTML to XHTML. Currently it looks like you are displaying the data as HTML (as <br> is an HTML tag), but eventually you are going to want to display the data as XHTML instead. The equivalent tag in XHTML is <br/>.

If you're storing the original version of the data then you can decide what format you are planning to display it in at the time when you display it. If you save it as HTML then you're making the decision that you're always going to display it as HTML. Which may not be true in two years time.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg


In reply to Re: Replacing new lines in multi line text box form fields with <br>. by davorg
in thread Replacing new lines in multi line text box form fields with <br>. by awohld

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.