#!/usr/bin/perl #Quickly written by Deltaray with the help from kind people on the #perl channel. use Tie::NetAddr::IP; my %netblocks; tie %netblocks, Tie::NetAddr::IP; $blocklist = '/home/mkrenz/netblocks2/biglist'; open(BLOCKLIST, $blocklist) || die(); # Assumes ' ' format to the file. while () { chomp($_); $line = $_; next if ($line =~ m/^#/); ($block, $country) = split(/\s+/, $line); $netblocks{$block} = $country; } close(BLOCKLIST); print "Ready\n"; while () { chomp($_); $ip = $_; $return = $netblocks{$ip}; if ($return) { print "$return\n"; } else { print "UNKNOWN\n"; } } untie %netblocks;