Debian Codegraph @

eg/lookup-ip-address

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use Data::Printer;
7 use Getopt::Long;
8 use MaxMind::DB::Reader;
9
10 sub main {
11 my ( $file, $ip );
12 GetOptions(
13 'file:s' => \$file,
14 'ip:s' => \$ip,
15 );
16
17 my $reader = MaxMind::DB::Reader->new( file => $file );
18 my $record = $reader->record_for_address($ip);
19
20 if ($record) {
21 p($record);
22 }
23 else {
24 print "No record found for $ip\n";
25 }
26 }
27
28 main();
29