geoip: remove %names map

This commit is contained in:
Jan Engelhardt
2010-12-17 22:41:08 +01:00
parent 0f42828fd6
commit f7c7264a65

View File

@@ -11,7 +11,6 @@ use Text::CSV_XS; # or trade for Text::CSV
use strict; use strict;
my %country; my %country;
my %names;
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
my $mode = "VV"; my $mode = "VV";
my $target_dir = "."; my $target_dir = ".";
@@ -29,10 +28,9 @@ if (!-d $target_dir) {
while (my $row = $csv->getline(*ARGV)) { while (my $row = $csv->getline(*ARGV)) {
if (!defined($country{$row->[4]})) { if (!defined($country{$row->[4]})) {
$country{$row->[4]} = []; $country{$row->[4]} = {name => $row->[5], pool => []};
$names{$row->[4]} = $row->[5];
} }
my $c = $country{$row->[4]}; my $c = $country{$row->[4]}{pool};
push(@$c, [$row->[2], $row->[3]]); push(@$c, [$row->[2], $row->[3]]);
if ($. % 4096 == 0) { if ($. % 4096 == 0) {
print STDERR "\r\e[2K$. entries"; print STDERR "\r\e[2K$. entries";
@@ -43,11 +41,11 @@ print STDERR "\r\e[2K$. entries total\n";
foreach my $iso_code (sort keys %country) { foreach my $iso_code (sort keys %country) {
printf "%5u ranges for %s %s\n", printf "%5u ranges for %s %s\n",
scalar(@{$country{$iso_code}}), scalar(@{$country{$iso_code}{pool}}),
$iso_code, $names{$iso_code}; $iso_code, $country{$iso_code}{name};
open(my $fh, "> $target_dir/".uc($iso_code).".iv0"); open(my $fh, "> $target_dir/".uc($iso_code).".iv0");
foreach my $range (@{$country{$iso_code}}) { foreach my $range (@{$country{$iso_code}{pool}}) {
print $fh pack($mode, $range->[0], $range->[1]); print $fh pack($mode, $range->[0], $range->[1]);
} }
close $fh; close $fh;