Article 10845 of comp.lang.perl:
Xref: feenix.metronet.com news.software.b:3215 comp.lang.perl:10845 alt.sources:2852
Path: feenix.metronet.com!news.ecn.bgu.edu!usenet.ins.cwru.edu!howland.reston.ans.net!europa.eng.gtefsd.com!library.ucla.edu!news.mic.ucla.edu!nntp.club.cc.cmu.edu!hudson.lm.com!epicycle.lm.com!not-for-mail
From: [email protected] (Tod McQuillin)
Newsgroups: news.software.b,comp.lang.perl,alt.sources
Subject: Perl source creates INN's unwanted groups
Followup-To: news.software.b
Date: 22 Feb 1994 01:38:46 -0500
Organization: Telerama Public Access Internet, Pittsburgh, PA
Lines: 52
Message-ID: <[email protected]>
NNTP-Posting-Host: epicycle.lm.com
Keywords: perl INN unwanted news.daily
X-Newsreader: TIN [version 1.2 PL2]

Archive-name: unwanted
Author: Tod McQuillin <[email protected]>
Version: 1.0

#!/usr/local/bin/perl
#
# unwanted 1.0 - offer to create unwanted newsgroups from INN's news.daily
#
#       perl program to scan a mailbox, find INN news.daily reports in it,
#       and summarise and offer to create the "Top unwanted newsgroups"
#       listed which haven't already been created
#
#       I'm not condoning this method of news administration, but here it
#       is for those who might benefit from it.
#
#       Usage: unwanted mbox-file
#
#       Tod McQuillin <[email protected]>

$active = '/usr/local/news/active';
$ctlinnd = '/usr/local/news/bin/ctlinnd';

while (<>) {
   if (/^From:\s+([^<]+\S)\s+<(.+)>/) {
       ($name, $addr) = ($1, $2);
       $fromnews = ($name =~ /News/i && $addr =~ /^news@/);
   }
   if (/^Top 20 unwanted newsgroups:/ && $fromnews) {
       while (<ARGV>) {
           if (/^\s+(\d+)\s+(.+)/) {
               $unwanted{$2} += $1;
           } elsif (/^\s*$/) {
               last;
           }
       }
   }
}

open(ACTIVE, $active) || die "Can't read active file ($!)\n";
while (<ACTIVE>) {
   /^(\S+)\s/ && $active{$1}++;
}
close ACTIVE;

for (sort {$unwanted{$b} <=> $unwanted{$a}} keys %unwanted) {
   if (!defined($active{$_})) {
       print "Create $_ (unwanted $unwanted{$_} times)? ";
       if (<STDIN> =~ /^y/i) {
           system $ctlinnd, "newgroup", $_;
       }
   }
}