http://www.perlmonks.org?node_id=52007


in reply to substitute an enter with regular expressions

Since you're putting real newline tags in, it's quite possible that other people might look at these entries. With that in mind, your substitute should keep things readable. Suppose my input looks like this:
Foo Bar Foobar

Then the actual string is "Foo\nBar\nFoobar\n". If I just ran a simple s/\n/<br>/g on the string, I'd get this output:
Foo<br>Bar<br>Foobar<br>

Clearly this would get illegible after 20 or so entries. So use a subtitute like this instead: s/\n/<br>\n/g
Your output should look like this:
Foo<BR> Bar<BR> Foobar<BR>


-Ted