#!/usr/local/bin/perl -w
use strict;
use Perlize;

my $kind;

while (<>)
 {
  if ($. == 1)
   {
    my ($leaf) = $ARGV =~ m#/([^/]+)$#;
    my $new    = "man/$leaf";
    close(FILE) if (defined fileno(FILE));
    open(FILE,">$new") || die "Cannot open $new:$!";
    print STDERR "$ARGV -> $new\n" 
   }
  print FILE Perlize::munge($_,\$kind);
  if (eof)
   {
    close(FILE) if (defined fileno(FILE));
    $. = 0;
    undef $kind;
   }
 }

