Ticket #1094: reproc-geoip.pl.txt

File reproc-geoip.pl.txt, 755 bytes (added by flyposted, 10 years ago)

Perl hack to reprocess GeoIP file to avoid bug

Line 
1#!/usr/bin/perl
2my $lside = 0;
3my $rside = 4294967295;
4my $lownum = "", $highnum = "";
5my $ccode = "";
6
7my $inputline = "";
8while (defined($inputline = <>)) {
9        chomp $inputline; $inputline =~ s/\s+//g;
10        if ($inputline =~ /^#/) { next; }
11        if ($inputline =~ /^$/) { next; }
12
13        ($lownum, $highnum, $ccode) = split(/,/, $inputline);
14
15    ### printf "[%s] [%s] [%s]\n", $lownum, $highnum, $ccode;
16
17    if ($lownum > $lside) {
18                my $lnumright = $lownum - 1;
19                printf "%s,%s,%s\n", $lside, $lnumright, "XX";
20        }
21        printf "%s,%s,%s\n", $lownum, $highnum, $ccode;
22        $lside = $highnum + 1;
23}
24if ($rside > $lside) {
25        printf "%s,%s,%s\n", $lside, $rside, "XX";
26}