#!/usr/bin/perl -w

use Date::Manip;

my $output = "";

my $inc = 0;

$artnum .= scalar(<>);  # art num
$newsgroups = <>;
$path = <>;
$date = <>;
$subject = <>;

$foo = $date;
chomp $foo;
$newdate = &ParseDate($foo);
# print "ND1: $newdate\n";
$newdate = &UnixDate($newdate, '%a, %d %b %Y %T GMT');
# print "ND2: $newdate\n";

@newsgroups = split(',', $newsgroups);
foreach $x (@newsgroups){
 $x = "oldnews." . $x;
}
$newnewsgroups = join(',', @newsgroups);

$output .= "Newsgroups: $newnewsgroups";
if ($subject =~ /\S/) {
 $output .= "Subject: $subject";
} else {
 $output .= "Subject: none\n";
}
$output .= "Date: $newdate\n";
$output .= "From: oldnews-conversion\@complete.org\n";
$output .= "Path: not-for-mail\n";
$foo = $artnum;
chomp $foo;
#$bar = $newsgroups;
#chomp $bar;
$output .= "Message-ID: <oldnews.conversion.$foo\@oldnews.complete.org>\n";
$inc += 1;
$output .= "\n";
$output .= $artnum;
$output .= $newsgroups;
$output .= $path;
$output .= $date;
$output .= $subject;
$output .= join('', <>);

sendit();

sub sendit {
 print "#! rnews " . length($output) . "\n";
 print $output;
 $output = '';
}