in reply to Formatting

Iam not a great guy in regular expression.

I have tried a little with regular expressions.

use strict; use warnings; undef $/; my $str; ($str=<DATA>)=~s{(((\n|^)K (.*?)(?=\n|$))+)}{"$3<p>".${($_=$1)=~s!(\n| +^)K !,%!g,\$_}."</p>"}eg; $str=~s/(<p>),/$1/g; print $str;

Please forgive any thing i have done silly in the above code.