#!/usr/bin/perl 
######################################################################
# newssub.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

use Net::NNTP;

my $nntphost = $ENV{NNTPSERVER}; # news server from environment variable

           # check news host
die "Unknown host $nntphost" unless gethostbyname($nntphost);

           # create newsagent and
           # connect to NNTP host
$newsagent = Net::NNTP->new($nntphost) || die "Cannot connect to host";  

           # set group and fetch article numbers
($nof_articles, $first, $last, $groupname) = 
                                  $newsagent->group("news.answers");

           # iterate through all articles of the newsgroup
for($newsagent->nntpstat($first); $newsagent->next();) {
    ($subjectref) = grep { $_->[0] eq "Subject" } 
                      map { [/^(\S+): (.*)/] } @{$newsagent->head()};
    print "Subject: $subjectref->[1]\n";
}

$newsagent->quit();

