2
# CellServDB merging script
3
# only tested on darwin systems
12
my ($cur,$in,$last,$new);
13
my ($line, $oline, $cell, $pos, $which);
16
$cur=new IO::File '<CellServDB';
17
$last=new IO::File '<CellServDB.master.last';
19
while (defined($line=<$cur>)) {
20
if ($line =~ /^>([-a-zA-Z0-9\._]+)\s/) {
23
if ($oline && $oline !~ /^>/) { # fewer servers in user's file than master
29
# start at the beginning of the old file, and find $cell
30
$last->seek(0,SEEK_SET);
32
if (/>$cell\s/) { # note that we don't compare the cell comments
40
die "First CellServDB line isn't a cell\n";
42
next if ($cellstat{$cell} == 2); # cell only in local CellServDB
43
next if ($cellstat{$cell} == 1); # already found a local change
45
if ($oline =~ /^>/) { # more servers in user's file than master
50
next if ($line eq $oline);
54
$cur->seek(0,SEEK_SET);
55
$cur=new IO::File '<CellServDB' or die "No CellServDB: $!\n";
56
$in=new IO::File '<CellServDB.master' or die "No CellServDB.master: $!\n";
57
$new=new IO::File '>CellServDB.NEW' or die "Cannot create output CellServDB: $!\n";
58
while (defined($line=<$cur>)) {
59
if ($line =~ /^>([-a-zA-Z0-9\._]+)\s/) {
61
$which=$cellstat{$cell};
63
$in->seek(0,SEEK_SET);
71
while (defined($line=<$in>) && $line !~ /^>/) {
78
die "First CellServDB line isn't a cell\n";
87
rename('CellServDB.NEW', 'CellServDB');
88
copy('CellServDB.master', 'CellServDB.master.last');