xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Net/demos/nntp (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/local/bin/perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse blib;
4*0Sstevel@tonic-gateuse Getopt::Long;
5*0Sstevel@tonic-gateuse Net::NNTP;
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gate$opt_debug = undef;
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gateGetOptions(qw(debug));
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate@groups = @ARGV;
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate$nntp = Net::NNTP->new('news', Debug => $opt_debug ? 1 : 0);
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateif($subs = $nntp->newsgroups)
16*0Sstevel@tonic-gate {
17*0Sstevel@tonic-gate  print join("\n",(keys %$subs)[0 .. 10]),"\n";
18*0Sstevel@tonic-gate }
19*0Sstevel@tonic-gate else
20*0Sstevel@tonic-gate {
21*0Sstevel@tonic-gate  warn $nntp->message;
22*0Sstevel@tonic-gate }
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateforeach $group (@groups)
25*0Sstevel@tonic-gate {
26*0Sstevel@tonic-gate  $new = $nntp->newnews(time - 3600, lc $group);
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate  if(ref($new) && scalar(@$new))
29*0Sstevel@tonic-gate   {
30*0Sstevel@tonic-gate    print@{$news}[0..3],"\n"
31*0Sstevel@tonic-gate        if $news = $nntp->article($new->[-1]);
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate    warn $nntp->message
34*0Sstevel@tonic-gate         unless $news;
35*0Sstevel@tonic-gate   }
36*0Sstevel@tonic-gate }
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate$nntp->quit;
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate
41