How to substitute
<p></p> # For the character <.
If character
'>'
exists at the end of the character <.
As in the data for a href..... <p></p> should not be substituted.

#!/usr/bin/perl while (<DATA>) { if($_ =~ /<.+>(<.+>)(.*)/){ $output = $1.$2; $output =~ s/(<|\\)/<\/p><p>/g; print $output; } } __DATA__ <BODY><![CDATA[<p>Developmentally, 2-year-olds are generally more inte +rested in themselves, while dogs do care how their people feel, and i +nstantly recognize a change in emotion.< "While your dog can't compre +hend that you just received a traffic violation, he can tell that you +'re upset the second you walk through the door," Coren says. "In fact +, dogs can detect some subtle changes which even adults can't," adds +Coren. "We can't smell cancer or predict seizures, as dogs can."< Whe +n I posted this story on my Facebook Fan page recently (<a href="http +://www.new.facebook.com/pages/ Steve-Dale/50057343596?ref=ts">www.new +.f acebook.com/pages/Steve-Dale/50057343596?ref=ts, or simply type St +eve Dale into the Facebook search), I received some interesting respo +nses:< Kelle: "Heck, my Italian Greyhound is smarter than most colleg +e students."< Karen: "Depends on how you define smart.


In reply to 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.