package ReportGen::RepFormat;
use strict;
require Exporter;
use vars qw( $OFile @ISA @EXPORT );
@ISA = qw ( Exporter );
@EXPORT = qw (
$OFile
&openReport &closeReport
&openSection &closeSection
);
use FileHandle;
$OFile = undef();
my $SectionId = 0;
my $SectionLevel = 0;
sub openReport {
my ($fname, $hname) = @_;
die("$hname") if defined $OFile; # one report at a time
$SectionId = 0;
$SectionLevel = 0;
$OFile = new FileHandle(">$fname");
die("$0: cannot create `$fname': $!\n") unless $OFile;
warn("$0: creating: `$fname'\n");
my $html = <<HEADER;
<html><head><title>PolyReport: $hname</title></head>
<body>
<p>This page was created by the Report Generator tool,
a part of the <a href="http://polygraph.ircache.net/">Web Polygraph</a>
benchmark.</p>
HEADER
print($OFile $html);
}
sub closeReport {
print($OFile "<br clear=all><hr noshade size=1>\n");
printf($OFile "<small>Generated on <em>%s</em> by <em>%s</em></small>\n",
scalar localtime(),
join(' ', $0, @ARGV),
);
print($OFile "</body></html>\n");
undef $OFile;
}
sub openSection {
my $title = shift;
$SectionId++;
print($OFile "<a name=Sec:$SectionId>");
printf($OFile "<h3>$SectionId. $title</h3>");
print($OFile "</a>\n");
$SectionLevel++;
die($SectionLevel) if $SectionLevel != 1; # not yet supported
}
sub closeSection {
die($SectionLevel) if $SectionLevel != 1; # not yet supported
$SectionLevel--;
}
1;
syntax highlighted by Code2HTML, v. 0.9.1