#!/usr/bin/perl

use CNGeoip;
use strict;

my $cngeoip = new CNGeoip('dbfile'=>"../cngeoip.dat") || die;

die "USAGE: $0 ip1 [ip2 ...]" unless ( @ARGV );
print "";
foreach my $ip ( @ARGV ) {
    print "=== $ip ===\n";
    my %res = $cngeoip->lookup($ip);
    foreach my $key ( keys %res ) {
	print "($key) => ($res{$key})\n";
    }
    foreach my $item ( @{$res{'items'}} ) {
	print "item : (", join(")(", @{$item}), ")\n";
    }
    print "\n";
}

