#!/usr/bin/perl

use strict;

undef $/;
my $html=<>;

$html=~s/<!--\s.*?-->//gs;
$html=~s(<A\s+HREF="(?:#|mailto:)[^"]*">(.*?)</A>)($1)gs;

$html=~s/^(.*<BODY\b[^<]*>\s*)//si
  and my $head=$1
    or die "Can't get head\n";
$html=~s#(</BODY>.*)##s
  and my $foot=$1
    or die "Can't get foot\n";

my @pages=split /<HR>\s*/,$html;
foreach(@pages){
  s/<P>\s*(<H|$)/$1/;
}

print
  $head,
  map(qq(
    <TABLE height="100%">
      <TR align=left valign=top height="100%">
	<TD align=left valign=top height="100%">
	  $_
	</TD>
      </TR>
    </TABLE>
  ),@pages),
  qq(
    <TABLE height="100%">
      <TR height="100%">
	<TD height="100%">&nbsp;</TD>
      </TR>
    </TABLE>
  ),
  $foot,
;


