Skip to content

Instantly share code, notes, and snippets.

@draegtun
Created September 16, 2011 19:16
Show Gist options
  • Save draegtun/1222875 to your computer and use it in GitHub Desktop.
Save draegtun/1222875 to your computer and use it in GitHub Desktop.
Find Hacker News (HN) users on MetaCPAN
#!/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