From 1ddd21105b4fdf68756a8676a58105927254d386 Mon Sep 17 00:00:00 2001 From: minima Date: Sun, 13 Oct 2002 23:25:50 +0000 Subject: [PATCH] fix USDB.pm so it uncompresses to a file --- perl/USDB.pm | 17 +++++++++++++---- perl/gen_usdb_data.pl | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/perl/USDB.pm b/perl/USDB.pm index 4cd4143b..3ee18825 100644 --- a/perl/USDB.pm +++ b/perl/USDB.pm @@ -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; diff --git a/perl/gen_usdb_data.pl b/perl/gen_usdb_data.pl index 153a5601..d4edaafa 100755 --- a/perl/gen_usdb_data.pl +++ b/perl/gen_usdb_data.pl @@ -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; -- 2.43.0