#!/usr/bin/perl -w use strict; use constant DEBUG => 1; #makes lines easier to see on screen while () { if ( my ($title, $body) = ($_ =~ /.*?(<p>.+?)<BODY>.*?(<p>.*)/)[0,1] ) { $title .= "</p>"; $body .= "</p>"; $title =~ s|<[^a/p]|<p>|g; $title =~ s|.<p>|.</p><p>|g; $title =~ s|</p>|</p>\n|g if DEBUG; $body =~ s|<[^a/p]|<p>|g; $body =~ s|.<p>|.</p><p>|g; $body =~ s|</p>|</p>\n|g if DEBUG; print "<TITLE>\n$title\n\n", "<BODY>\n$body\n"; } }