in reply to Truncating real text

my goal here was to split the body of an article into the first paragraph and the rest, so an advert can be inserted. Since these are html articles, a paragraph is defined by a <p> or <br> tag, and since it's news the end punctuation will either be a period or a double quote.

my $len = length($story->{body}); $len = $len > 800 ? 400 : $len < 150 ? 0 : 150; ($para1,undef,$story) = $story->{body} =~ /(.{$len,}?\.["]?)\W*<(p|br\ +/?)>(.*)/s;