App-ipinfo
view release on metacpan or search on metacpan
lib/App/ipinfo.pm view on Meta::CPAN
#!perl
use utf8;
use v5.20;
use strict;
use open qw(:std :utf8);
use experimental qw(signatures);
package App::ipinfo;
use Carp qw(croak);
use Geo::IPinfo;
use Encode qw(decode);
use String::Sprintf;
our $VERSION = '1.01';
__PACKAGE__->run(@ARGV) unless caller();
=encoding utf8
=head1 NAME
App::ipinfo - a command-line tool for IPinfo.io
=head1 SYNOPSIS
Call it as the program:
% ipinfo '%c' [ip addresses]
Do it all at once:
use App::ipinfo;
App::ipinfo->run( \%options, @ip_addresses );
Control most of it yourself:
use App::ipinfo;
my $app = App::ipinfo->new(
template => '%c',
token => ...,
);
foreach my $ip ( @ip_addresses ) {
my $info = $app->get_info($ip);
next unless defined $info;
$app->output( $app->format($info) );
}
=head1 DESCRIPTION
=head2 Formatting
Most of the data provided by IPinfo has an C<sprintf>-style formatting
code, and for everything else you can use C<%j> to get JSON that you can
format with B<jq> for some other tool.
=over 4
=item * C<%a> - the ASN of the organization
=item * C<%c> - the city of the organization
=item * C<%C> - the country code of the organization
=item * C<%f> - the emoji flag of the country
=item * C<%h> - the hostname for the IP address
=item * C<%i> - the IP address
=item * C<%j> - all the data as JSON, in a UTF-8 decoded string
=item * C<%k> - the continent of the organization
=item * C<%L> - the latitude of the organization
( run in 1.499 second using v1.01-cache-2.11-cpan-5a3173703d6 )