| 1 | #!/usr/local/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use utf8; | ||
| 5 | use Simple::IPInfo; | ||
| 6 | |||
| 7 | use Getopt::Std; | ||
| 8 | my %opt; | ||
| 9 | getopt( 'fditsH', \%opt ); | ||
| 10 | |||
| 11 | $opt{d} ||= "$opt{f}.csv"; | ||
| 12 | $opt{i} ||= 0; | ||
| 13 | $opt{s} ||= ','; | ||
| 14 | $opt{H} ||= 0; | ||
| 15 | $opt{type} = ($opt{t} and $opt{t} eq 'as') ? $Simple::IPInfo::IPINFO_AS_F : $Simple::IPInfo::IPINFO_LOC_F; | ||
| 16 | $opt{names} = ($opt{t} and $opt{t} eq 'as') ? [ 'as' ] : [ qw/country area isp country_code area_code isp_code/ ]; | ||
| 17 | |||
| 18 | iterate_ipinfo( | ||
| 19 | $opt{f}, #inet-sorted file | ||
| 20 | i => $opt{i}, | ||
| 21 | write_file => $opt{d}, | ||
| 22 | sep => $opt{s}, | ||
| 23 | charset => 'utf8', | ||
| 24 | return_arrayref => 0, | ||
| 25 | ipinfo_file => $opt{type}, | ||
| 26 | ipinfo_names => $opt{names}, | ||
| 27 | skip_head => $opt{H} ? 1 : 0, | ||
| 28 | ); |