document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4.  
  5. # Range start - Range End : CIDR of Range : ISO Country : Enclosing non-CIDR range : Home Registry : Possibly other fields
  6. # 1.0.0.0 - 1.7.255.255 : 1.0/13 : au : 1.0.0 - 1.10.10 : APNIC
  7.  
  8. use Net::IP;
  9.  
  10. while (<>) {
  11.     next if m/\\W*#/;
  12.     chomp;
  13.     my ($ip_range, $cidr, $country, undef, undef) = split / : /;
  14.  
  15.     if ($country eq \'cn\') {
  16.         my $ip = new Net::IP("$ip_range")
  17.             or warn "Failed to parse IP range: $ip_range\\n";
  18.         my $net = $ip->ip();
  19.         my $msk = $ip->mask();
  20.         print "$net/$msk/$country\\n";
  21.     }
  22. }
');