#! /usr/bin/perl -w
use diagnostics;
use strict;
use Date::Format;

my $fromdate = time2str("%a %b %e %T %Y %z", time, 'GMT');
my $headerdate = time2str("%a, %e %b %Y %T %z", time, 'GMT');

local $/ = "\n\n";

while (<>)
{
    /^Package: (.*)/m;
    my $package = $1;
    /^Section: (.*)/m;
    my $section = $1;
    $section =~ s|/|.|g;
    /^Maintainer: (.*)/m;
    my $maintainer = $1;
    $maintainer =~ /<(.*)>/;
    my $maintaddr = $1;
    /^Description: (.*)/m;
    my $shortdesc = $1;
    s/^ (.*)//ms;
    my $longdesc = $1;
    $longdesc =~ s/^ //gm;
    $longdesc =~ s/^\.$//gm;
    $_ = "From $maintaddr $fromdate\n" .
	 "From: $maintainer\n" .
	 "Date: $headerdate\n" .
	 "Subject: $package - $shortdesc\n" .
	 "Newsgroups: $section\n" .
	 "$_\n$longdesc";
    print $_;
}

