]> dxcluster.net Git - spider.git/commitdiff
fix USDB.pm so it uncompresses to a file
authorminima <minima>
Sun, 13 Oct 2002 23:25:50 +0000 (23:25 +0000)
committerminima <minima>
Sun, 13 Oct 2002 23:25:50 +0000 (23:25 +0000)
perl/USDB.pm
perl/gen_usdb_data.pl

index 4cd4143bd3b7aca6794a188678ba8d43a3f2b2cb..3ee18825d04b89754a8d2c1a8559f3768fe58857 100644 (file)
@@ -103,9 +103,17 @@ sub load
        # now write away all the files
        for (@_) {
                my $fn = shift;
-               my $f = gzopen($fn, "r") or return "Cannot open $fn $!";
-               my $l;
-               while ($f->gzreadline($l)) {
+               my $if = gzopen($fn, "r") or return "Cannot open $fn $!";
+               my $ofn = "$fn.upk";
+               my $of = new IO::File "+>$ofn" or return "Cannot open $ofn $!";
+               my ($l, $buf);
+               while ($l = $if->gzread($buf)) {
+                       $of->write($buf, $l);
+               }
+               $if->gzclose;
+               $of->seek(0, 0);
+
+               while ($of->getline()) {
                        chomp $l;
                        my ($call, $city, $state) = split /\|/, $l;
                        
@@ -122,7 +130,8 @@ sub load
                        }
                        $dbn{$call} = $ctyn; 
                }
-               $f->gzclose;
+               $of->close;
+               unlink $ofn;
        }
        
        untie %dbn;
index 153a560153b5ab025e503d2a92e845f707372b5c..d4edaafade903da192bfd97716bb7160d488c54c 100755 (executable)
@@ -60,7 +60,7 @@ my $dbrawfn = "$main::data/usdbraw";
 rename "$dbrawfn.oo", "$dbrawfn.ooo";
 rename "$dbrawfn.o", "$dbrawfn.oo";
 rename "$dbrawfn", "$dbrawfn.o";
-my $gzfh = gzopen($dbrawfn, "wb9") or die "Cannot open $dbrawfn $!";
+my $gzfh = gzopen($dbrawfn, "wb") or die "Cannot open $dbrawfn $!";
 
 my $ctycount;