Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Help with Geo::IP output

by Anonymous Monk
on Jun 24, 2020 at 12:05 UTC ( #11118416=note: print w/replies, xml ) Need Help??

in reply to Re: Help with Geo::IP output
in thread Help with Geo::IP output

Thanks you for much for the example.

How do you call it from your script after you have installed the module?

Replies are listed 'Best First'.
Re^3: Help with Geo::IP output
by Tux (Abbot) on Jun 24, 2020 at 12:58 UTC

    Currently you don't. It is a module in the App:: namespace. If you want to use the infrastructure generated by geoip steal the code from geoip or use it's json output in a pipe:

    use JSON::MaybeXS; open my $gh, "-|", "geoip", "--json", $url_or_hostname or die; my $data = decode_json (do { local $/; <$gh> }); say $data->[0]{provider}; # [0] as it returns a list of matches

    Enjoy, Have FUN! H.Merijn

      As with the other post today, in a piped open, close needs to be checked for errors as well. Or, let me just plug my relatively new module IPC::Run3::Shell::CLIWrapper ;-)

      use JSON::PP qw/decode_json/; use IPC::Run3::Shell::CLIWrapper; my $geoip = IPC::Run3::Shell::CLIWrapper->new( { fail_on_stderr=>1, stdout_filter => sub {$_=decode_json($_)} }, qw/ geoip --json --DB=dbi:SQLite:dbname=geoipdb / ); my $data = $geoip->('');

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11118416]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2021-02-24 21:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found