Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Geo::IP;
- use Data::Dumper;
- my @rawlines;
- my $region;
- my $gi = Geo::IP->open('/home/kovensky/GeoIPCountryWhois.csv', GEOIP_INDEX_CACHE) or die $!;
- map {
- my $ip = $_ =~ m/\(host=(\d+.\d+.\d+.\d+)/;
- if ( defined($region->{$ip}) ) {
- next;
- }
- print $ip . "\n";
- my $record = $gi->record_by_addr($ip);
- $region->{$ip}->{continent} = $record->continent_code;
- $region->{$ip}->{country} = $record->country_name;
- } grep /connection established/, <>;
- print Dumper($region);
Add Comment
Please, Sign In to add comment