summaryrefslogtreecommitdiff
path: root/cpan/libnet/demos/nntp
blob: 7753fbc2991cc87401727186be6c57d17c67941f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/local/bin/perl

use blib;
use Getopt::Long;
use Net::NNTP;

$opt_debug = undef;

GetOptions(qw(debug));

@groups = @ARGV;

$nntp = Net::NNTP->new('news', Debug => $opt_debug ? 1 : 0);

if($subs = $nntp->newsgroups)
 {
  print join("\n",(keys %$subs)[0 .. 10]),"\n";
 }
 else
 {
  warn $nntp->message;
 }

foreach $group (@groups)
 {
  $new = $nntp->newnews(time - 3600, lc $group);

  if(ref($new) && scalar(@$new))
   {
    print@{$news}[0..3],"\n"
        if $news = $nntp->article($new->[-1]);

    warn $nntp->message
         unless $news;
   }
 }

$nntp->quit;