#!/usr/bin/perl

($file, $section) = @ARGV;
$section ||= 1;

open(F, $file) or die "$file: $!";

($base = $file) =~ s/\..*//;

$rev = "PPT";

while (<F>) {
    if (/\$Revision: (.*?) \$/) {
	$rev = "v$1";
    } 
} 

require POSIX;

$pid = open(POD, "-|");
die "no fork: $!" unless defined $pid;

$tool = { 1 => "Tools", 6 => "Games" }->{$section};

unless ($pid) { 
    exec("pod2man", "--section=$section", "--date=$rev",
	    "--center=Perl Power $tool",
	    POSIX::strftime("--release=%B %d, %Y", localtime((stat($file))[9])),
	    $file);
    die "no exec: $!";
}

while (<POD>) {
    s/^(\.TH \w+)\.\S+/$1/;
    print;
} 
