Article View: news.software.b
Article #5017Perl source creates INN's unwanted groups
From: Tod McQuillin
Date: Tue, 22 Feb 1994 06:38
Date: Tue, 22 Feb 1994 06:38
52 lines
1961 bytes
1961 bytes
Archive-name: unwanted
Author: Tod McQuillin <devin@lm.net>
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 <devin@lm.com>
$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", $_;
}
}
}
Technical Details
Message-ID:
<2kc99m$hvp@epicycle.lm.com>Path:
arc1-ca.pugleaf.net!wupost!math.ohio-state.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-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!math.ohio-state.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: devin@epicycle.lm.com (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: <2kc99m$hvp@epicycle.lm.com> NNTP-Posting-Host: epicycle.lm.com Keywords: perl INN unwanted news.daily X-Newsreader: TIN [version 1.2 PL2]