tool to convert 0.2.2 and earlier caches to new format
This commit is contained in:
parent
4024336ba5
commit
1368db7d66
1 changed files with 30 additions and 0 deletions
30
trunk/ripnews/tools/cacheconverter
Executable file
30
trunk/ripnews/tools/cacheconverter
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
my %servers;
|
||||
|
||||
$cachefile = $ARGV[0];
|
||||
if ($ARGV[1]) {
|
||||
print "Usage: $ARGV[0] <cachefile>\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
print "Group: $groupname\n";
|
||||
|
||||
while (<>) {
|
||||
/^([^|]*)\|([^|]*)\|([^|]*)\|(.*)/;
|
||||
if (exists $servers{$3}) {
|
||||
push @{$servers{$3}}, "$1|$2|$4\n";
|
||||
} else {
|
||||
$servers{$3} = [];
|
||||
push @{$servers{$3}}, "$1|$2|$4\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %servers) {
|
||||
print ":KEY: $_\n";
|
||||
open FH, ">$cachefile.$_" or die "Couldn't write new cachefile\n";
|
||||
foreach (@{$servers{$_}}) {
|
||||
print FH;
|
||||
}
|
||||
close FH;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue