🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #649

Re: Wanted: SIMPLE .newsrc sorter

#649
From: Chip Salzenberg
Date: Fri, 27 Sep 1991 19:17
54 lines
2135 bytes
Here's our local Perl script: "sortnewsrc".

===========================================================================
eval 'exec /bin/perl -S $0 ${1+"$@"}'
	if 0;

# $Id: sortnewsrc,v 1.1 1990/10/03 11:19:37 news Exp news $
#
# Sort a user's .newsrc file.
#

@H = (	"general", "tct", "tba", "fl",
      	"news", "comp",
	"gnu", "biz", "pubnet",
	"sci", "rec", "soc", "talk", "misc",
	"alt" );

$x = "a";
foreach $h (@H) {
	$X{$h} = $x;
	++$x;
}
$X{"other"} = $x;

chdir $ENV{"HOME"} || die "can't change to home directory: $!\n";

open(RC, ".newsrc") || die "can't open .newsrc: $!\n";
while (<RC>) {
	chop;
	next unless ($group, $rest) = /^([^:!]+)([:!].*)/;
	($hier) = split(/\./, $group);
	$x = $X{$hier} || $X{"other"};
	push(@G, $x . "*" . $group . "*" . $rest);
}
close(RC);

@G = sort @G;

open(NRC, ">.newnewsrc") || die "can't create .newnewsrc: $!\n";
foreach $g (@G) {
	($a, $b, $c) = split(/\*/, $g, 3);
	print NRC $b, $c, "\n";
}
close(NRC);

unlink(".oldnewsrc");
rename(".newsrc", ".oldnewsrc") || die "can't rename .newsrc: $!\n";
rename(".newnewsrc", ".newsrc") || die "can't rename .newnewsrc: $!\n";
===========================================================================
-- 
Chip Salzenberg at Teltronics/TCT   <chip@tct.com>, <73717.366@compuserve.com>
           "There is no such thing as a bogus newsgroup in 'alt'."
                  -- Bruce "Every Newsgroup Sacred" Becker
Technical Details
Message-ID: <28E383D1.1CCD@tct.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.perl.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!fauern!ira.uka.de!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!uunet!ndcc.ndcc.com!myrddin!tct!chip
References: <36690@hydra.gatech.EDU>

Show Full Headers
Complete Article Headers
Message-ID: <28E383D1.1CCD@tct.com>
Subject: Re: Wanted: SIMPLE .newsrc sorter
Date: Fri, 27 Sep 1991 19:17:37 +0000
From: chip@tct.com (Chip Salzenberg)
References: <36690@hydra.gatech.EDU>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.perl.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!fauern!ira.uka.de!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!uunet!ndcc.ndcc.com!myrddin!tct!chip
Newsgroups: news.software.readers,comp.lang.perl
Organization: TC Telemanagement, Clearwater, FL
Lines: 53