1#!/usr/bin/perl
2
3$spooldir = "/var/spool/news";
4
5undef $/;
6if ( chdir "$spooldir/out.going" && opendir( DIR, "." ) ) {
7    @files = readdir( DIR );
8    closedir( DIR );
9
10    foreach (@files) {
11	if ( open(F, "< $_") ) {
12	    undef $subject, $newsgroups, $from;
13	    $_ = <F>;
14	    close F;
15	    s/\n\n.*//s;
16	    s/\r//gs;
17	    s/\n\s+/ /sg;
18	    foreach ( split( /\n/, $_ ) ) {
19		$subject = $1 if ( /^Subject:\s+(.*)/i );
20		$newsgroups = $1 if ( /^Newsgroups:\s+(.*)/i );
21		$from = $1 if ( /^From:\s+(.*)/i );
22	    }
23	    print $from, " in ", $newsgroups, "\n\t", $subject, "\n",
24		if ( $subject ne "" && $from ne "" && $newsgroups ne "" );
25	}
26    }
27}
28