line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
314368
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
3
|
|
|
|
|
|
|
package WWW::ipinfo; |
4
|
|
|
|
|
|
|
$WWW::ipinfo::VERSION = '0.04'; |
5
|
1
|
|
|
1
|
|
1320
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
128897
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
24
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
1515
|
use JSON; |
|
1
|
|
|
|
|
20128
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Returns your ip address and geolocation data using L |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
1
|
|
|
1
|
|
5
|
require Exporter; |
14
|
1
|
|
|
1
|
|
186
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
128
|
|
15
|
1
|
|
|
|
|
4
|
our @EXPORT = 'get_ipinfo'; |
16
|
1
|
|
|
|
|
134
|
our @EXPORT_OK = (); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_ipinfo { |
22
|
2
|
|
|
2
|
1
|
11
|
my $ip = shift; |
23
|
2
|
100
|
|
|
|
12
|
my $url = $ip ? "http://ipinfo.io/$ip/json" : "http://ipinfo.io/json"; |
24
|
2
|
|
|
|
|
21
|
my $response = HTTP::Tiny->new->get($url); |
25
|
2
|
50
|
0
|
|
|
1576589
|
die join(' ', 'Error fetching ip: ', |
|
|
|
0
|
|
|
|
|
26
|
|
|
|
|
|
|
($response->{status} or ''), |
27
|
|
|
|
|
|
|
($response->{reason} or '')) unless $response->{success}; |
28
|
2
|
|
|
|
|
65
|
decode_json($response->{content}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |