Article 2279 of alt.sources:
Xref: feenix.metronet.com alt.sources:2279
Newsgroups: alt.sources
Path: feenix.metronet.com!news.utdallas.edu!hermes.chpc.utexas.edu!cs.utexas.edu!howland.reston.ans.net!xlink.net!pilhuhn!snert!hwr
From: hwr@pilhuhn.sub.org (Heiko W.Rupp)
Subject: sys2gup - convert from C News sys-Files to gup dirs 4 with INN
Date: Thu, 18 Nov 1993 11:14:17 GMT
Organization: The home of the Pilhuhn
Message-ID: <CGopvu.os@pilhuhn.sub.org>
Lines: 78

Hi,
this is my first version of sys2gup, a script, which converts from C
News sys-files to the directories used by gup when running INN. The
script does a conversion from sys to newsfeeds format. It is f*ucking
slow, as the grep is slow - any suggestions to increase speed are
welcome. 

-----------------------------------------------------------------------
#!/usr/local/bin/perl
#
# sys2gup - convert from C News sys-file Format to gup sitedirs
# by Heiko W.Rupp hwr@pilhuhn.sub.org
#
# $Header: /hacking/heiko/gup/scripts/sys2gup,v 1.1 93/11/18 12:06:38 hwr Exp Locker: hwr $
# $Log:	sys2gup,v $
# Revision 1.1  93/11/18  12:06:38  hwr
# Initial revision
# 
#
$gupdir="/usr/lib/news/gup/sites";# dir, where site information for gup is
$sys="/usr/lib/news/sys";	      # location of input sys-File

open(IN,$sys) || die "No sys-File found!\n" ;
open(ACTIVE,"/usr/lib/news/active") || die "Can't open active\n";


#get active
@active=<ACTIVE>;
foreach $elem (@active) {
	$elem =~ s/ .*//;
	chop ($elem);
}

while(<IN>) {
    chop;
    next if /^#/;                  # Skip comment lines
    $spool = "";
    $x = $_;
    while($x !~ /^#/) {
			$x =~ s/\\//gi;        # remove trailing backslash
			$x =~ s/^ *//;         # remove unnexeccary leading spaces
			$spool .= $x;
			chop($x = <IN>);
    }
    ($site, $groups, $command, $param) = split(/:/,$spool);
    $site =~ s/\/.*//;             # skip other pathhosts
	$groups =~ s/\s*//g;	       # remove spaces in group list
    print "Site is $site \n";
   	open(OUT,">$gupdir/$site/groups") ||
		die "Can't open sitedir - shouldn't happen"; 
    $groups =~s/\/.*//;            # skip distributions
    @entries = split(/,/,$groups);
    foreach $group (@entries) {
		$neg = 0;
		do {				       # exclude pattern
			$neg = 1;
			$group =~ s/\!//;
		} if $group =~ /^!.*/;
		$egroup = $group .".";
print "|$group \b|\n";
		if (grep (/$group/ , @active)) {  # group matches itself
			print OUT  "!" if $neg ==1;
			print OUT "$group\n";
		}
		if (grep (/$egroup/ , @active)) { # Group is a hierarchie
			print OUT "!" if $neg ==1;
			print OUT"$group.*\n";
		}

   	} #foreach
	close(OUT);
}
--------------------------------------------------------------------------

-- 
Heiko W.Rupp        Gerwigstr.5        D-76131  Karlsruhe    +49 721 9661521
What would you term a successful computer date?
  "Hands-on experience."


