Created
September 16, 2011 19:16
-
-
Save draegtun/1222875 to your computer and use it in GitHub Desktop.
Find Hacker News (HN) users on MetaCPAN
This file contains hidden or 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 5.014; | |
use warnings; | |
use LWP::UserAgent; | |
use JSON 'decode_json'; | |
# Simple script to get MetaCPAN users that use Hacker News (http://news.ycombinator.com/) | |
my $ua = LWP::UserAgent->new; | |
my $res = $ua->get("https://api.metacpan.org/author/_search?q=author.profile.name:hackernews"); | |
die $res->status_line unless $res->is_success; | |
my $hn_users = decode_json $res->decoded_content; | |
my $hits = $hn_users->{hits}->{hits}; | |
for my $hit (@$hits) { | |
my $user = $hit->{_source}; | |
my $profiles = $user->{profile}; | |
my $hn_username = (grep { $_->{name} eq 'hackernews' } @$profiles)[0]->{id}; | |
say $user->{pauseid} . " (hn: $hn_username)"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment