Created
July 30, 2011 12:04
-
-
Save und3f/1115455 to your computer and use it in GitHub Desktop.
Search ukrainian authors on metacpan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use v5.10; | |
use LWP::UserAgent; | |
use JSON; | |
use Encode; | |
my $BASE = 'http://api.metacpan.org/v0/author/_search?q='; | |
my $ua = LWP::UserAgent->new; | |
foreach my $query (qw/country:UA country:ua/) { | |
my $response = $ua->get($BASE . $query); | |
die $response->status_line unless $response->is_success; | |
my $result = decode_json(encode 'utf8', $response->decoded_content); | |
my @authors = @{$result->{hits}->{hits}}; | |
display_author($_) foreach (@authors); | |
} | |
sub display_author { | |
my ($author) = @_; | |
say $author->{_source}->{name}, " ($author->{_id})", | |
" http://metacpan.org/author/$author->{_id}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment