#!/usr/bin/env perl
use strict;
# Range start - Range End : CIDR of Range : ISO Country : Enclosing non-CIDR range : Home Registry : Possibly other fields
# 1.0.0.0 - 1.7.255.255 : 1.0/13 : au : 1.0.0 - 1.10.10 : APNIC
use Net::IP;
while (<>) {
next if m/\\W*#/;
chomp;
my ($ip_range, $cidr, $country, undef, undef) = split / : /;
if ($country eq \'cn\') {
my $ip = new Net::IP("$ip_range")
or warn "Failed to parse IP range: $ip_range\\n";
my $net = $ip->ip();
my $msk = $ip->mask();
print "$net/$msk/$country\\n";
}
}