in reply to Paragraph break

Perl 5.10+:

my $text = do { local $/; <DATA> }; $text =~ s/\A.*\K\\$//sm; $text =~ s/\\$/<br>/mg;

Any version:

my $text = do { local $/; <DATA> }; $text =~ s/(.*)\\$/$1/ms; $text =~ s/\\$/<br>/mg;

Replies are listed 'Best First'.
Re^2: Paragraph break
by gem555 (Acolyte) on Sep 02, 2009 at 06:00 UTC
    #!/usr/bin/perl my $text; while (my $line = <DATA>){ $line =~ s/\\/<br>/; $text .= $line; } $text =~ s[<br>\s*<\/w*>][<\/w*>]s; print $text; __DATA__ <p> This affected me deeply because I was being treated for depression the +n. I felt she was replacing me as mother and grandmother.\ This scenario occurred as often as two to three times a week.\ Somehow, all of those present seemed to think I should be her "friend. +" Shouldn't I be allowed to choose whom I want to associate with? Now, add the fact that my sister and her husband are still very attached to my ex, as they should be.\ </p>
    Why does the script doesn't work. The expected output should be something similar as below
    <p> <br>This affected me deeply because I was being treated for depression + then. I felt she was replacing me as mother and grandmother.<br> This scenario occurred as often as two to three times a week.<br> Somehow, all of those present seemed to think I should be her "friend. +" Shouldn't I be allowed to choose whom I want to associate with? Now, add the fact that my sister and her husband are still very attached to my ex, as they should be.<br/> </p>
      It does work except for the fixing the last <br>. Revert the change you made and it will work.