I'm having a hard time with what I'm sure is a simple thing. I am making html pages out of a large number of text files.
I have code that adds markup for everything I want except paragraph formatting.
All of the text I am concerned with is in an array (@ThisFileArray), and it's just a bunch of text, with paragraphs separated by an extra newline. Kind of like this:

Text blah blah, make my point here. More text and even more continuing on along the way.

New paragraph starts here, there were 2 newlines just before I started this paragraph, so I should somehow be able
to match on that, but I can't figure out how to search for that through my array.

If I could do that, then I would search something like:
s/\n\n/</p>\n\n\<p>/m
so that I would add a close paragraph tag at the end of the previous paragraph,
and an open paragraph tag at the beginning of the next.
Of course, I want to add a <p> tag at the beginning of the array, to insert it at the beginning
of the text, and then add one final </p> tag at the end of the text, to make everything really nice.
The end result would be (ideally) something like this:

<p>Text blah blah, make my point here. More text and even more continuing on along the way.</p>

<p>New paragraph starts here, there were 2 newlines just before I started this paragraph, so I should somehow be able
to match on that, but I can't figure out how to search for that through my array.</p>

I have tried this:
while (<@ThisFileArray>) { s/\n\n/</p>\n\n<p>/m }
But clearly I am missing some key ingredient here, because it doesn't work. Can anyone provide some enlightenment to this frustrated newbie? Thanks so much. Mark

In reply to question on multi line pattern matching for html formatting by tallCoolOne

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.