in reply to p tag substitution

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.