sub html {
    local($file, @format) = @_;

    print("Writing HTML\n");
    open(MAIL, ">>$file");
    select(MAIL);
    print("<h1>$first_time --> $last_time</h1><pre>\n");
    &ascii(@format);
    print("</pre>\n");
    select(STDOUT);
    close(MAIL);
}

sub ascii {
    local(@options) = @_;
    local(@format) = @options;

    $format=join(" ", @format);
    ($fmt=$format) =~ s/key(\d+)/&pad(\$key, \1), /g;
    $fmt =~ s/hits(\d+)/&pad(\$value, \1), /g;
    $fmt =~ s/, $//;
    
    print($report[1], "\n");
    print("$first_time ---> $last_time\n");
    @repdata = @report[2..$#report];
    while ($key = shift(@repdata)) {
	$value = shift(@repdata);
	eval("print($fmt);");
	print("\n");
    }
    print("Total: $report[0]\n");
    
}

sub mail {
    local($who, @format) = @_;

    print("Sending mail to \"$who\"\n");
    open(MAIL, "|/usr/lib/sendmail -fmkgray@mit.edu $who");
    select(MAIL);
    print("To: $who\n");
    print("From: WebReport <mkgray@mit.edu>\n");
    print("Subject: Your WebReport Results\n\n");
    &ascii(@format);
    select(STDOUT);
    close(MAIL);
}

1;
