!/usr/bin/env perl

use Modern::Perl;

use Geo::Coder::OSM;

use Encode::Locale;

use Encode;

binmode(STDOUT, ':utf8'); # force UTF-8 output

my $geocoder = Geo::Coder::OSM->new;

my $usage = <<"EOT";

$0 [location]

Print latitude and longitude for the given location.

EOT

my $location = decode(locale => "@ARGV");

my @locations = $geocoder->geocode(location => $location);

for (@locations) {

say $_->{display_name};

say "lat: ", $_->{lat}, " lon: ", $_->{lon};

}