Since you didn't show us desired output, I suspect your spec if faulty because what you show would not result in reasonable .html.

So, taking a guess (possibly wrong), if you're looking for this:

<p>Developmentally, 2-year-olds are generally more interested in thems +elves, while dogs do care how their people feel, and instantly recogn +ize a change in emotion.</p> <p>"While your dog can't comprehend that you just received a traffic v +iolation, he can tell that you're upset the second you walk through t +he door," Coren says. "In fact, dogs can detect some subtle changes w +hich even ad ults can't," adds Coren. "We can't smell cancer or predict seizures, a +s dogs can."</p> <p>When I posted this story on my Facebook Fan page recently (<a href= +"http://www.new.facebook.com/pages/ Steve-Dale/50057343596?ref=ts">ww +w.new.f acebook.com/pages/Steve-Dale/50057343596?ref=ts, or simply ty +pe Steve Dal e into the Facebook search), I received some interesting responses:</p +> <p>Kelle: "Heck, my Italian Greyhound is smarter than most college stu +dents."</p>

you could do this to the data you supplied (which, IMO, implies that you want to replace only those "<" which are followed directly by a space):

#!/usr/bin/perl use strict; use warnings; my $output; while (<DATA>) { if ($_ =~ /<.+>(<.+>)(.*)/){ $output = $1.$2; $output =~ s/<!\[CDATA\[(.*)/$1/; # print $output; } print "\n\n"; $output =~ s!(< )!</p>\n\n<p>!g; print $output . '</p>' . "\n"; }

But, as GrandFather said,

DON'T DO THIS!
There are too many corner cases, "gotchas," and other complications to make "rolling your own" profitable.


In reply to Re: p tag substitution by ww
in thread p tag substitution by Anonymous Monk

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.