--- Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote: > I've gone through and read all the other posts in > reply to this, and they > all seem to ignore a very simple solution. > > First: strip off the \r\n: > s/\r\n/\n/sg > > Then look for the pattern \n\n (which would indicate > the existence of an > empty line. For example: "Some paragraph text\n\nA
I've got my solution, it's something like yours, and it works fine. The main difference was I explicitely used \x0d and \x0a because I wasn't sure if \n and \r were defined to the same ASCII codes on all platforms. Any double newlines I assume the user meant a paragraph, any single ones just a line break. Here's the code I finally used (embedded tags, sorry if code wraps in ugly places due to this silly Yahoo editor): sub NL2HTML { $_ = shift; s/\x0d\x0a/\x0d/g; # Strip LF out of CR/LF combinations (Convert DOS -> *nix) s/\x0d{2}|\x0a{2}/<\/p><p>/g; # Replace double CR or LF with paragraph break s/\x0d|\x0a/<br>/g; # Replace single CR or LF with line break return "<p>$_</p>"; # Wrap whole thing in outside <p></p> } ===== "When you're following an angel, does it mean you have to throw your body off a building?" - They Might Be Giants, http://www.tmbg.com ---- Word of the week: Serendipity, see http://www.bartleby.com/61/93/S0279300.html __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]