#!/usr/bin/perl use strict; use warnings; use DBI; # TODO cmd line option to actually delete the groups # TODO use LWP::UserAgent to fetch a file and load it $\="\n"; my $db = DBI->connect(undef,undef,undef,{RaiseError=>1,AutoCommit=>0}); $db->do('create temp table newnewsgroups (like newsgroups including defaults)'); $db->do('create index newnewsgroups_idx on newnewsgroups(newsgroup)'); my $i = $db->prepare('insert into newnewsgroups (newsgroup,posting,creator) values (?,?,?)'); my $rmgroup = $db->prepare('update newsgroups N set active = false where local != true and not exists (select newsgroup from newnewsgroups where newsgroup = N.newsgroup)'); my $newgroup = $db->prepare('insert into newsgroups select * from newnewsgroups N where not exists (select 1 from newsgroups where newsgroup = N.newsgroup)'); while (<>) { chomp; my ($group, undef, undef, $mod) = split(/\s+/, $_); $i->execute($group,$mod,'iscactivefile'); } $rmgroup->execute(); $newgroup->execute(); $db->commit; __END__ aaa.inu-chan 0000000000 0000000001 m ab.arnet 0000000000 0000000001 m ab.general 0000000000 0000000001 y ab.jobs 0000000000 0000000001 y ab.politics 0000000000 0000000001 y abg.allgemein 0000000000 0000000001 y abg.amiga 0000000000 0000000001 y abg.comp 0000000000 0000000001 y abg.diskussion 0000000000 0000000001 y abg.english 0000000000 0000000001 y