Skip to content

Instantly share code, notes, and snippets.

@und3f
Created July 30, 2011 12:04
Show Gist options
  • Save und3f/1115455 to your computer and use it in GitHub Desktop.
Save und3f/1115455 to your computer and use it in GitHub Desktop.
Search ukrainian authors on metacpan
#!/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