Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created June 26, 2016 19:26
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bessarabov/a280c78781b8e8b0db2bfd3e96d13944 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use feature 'say';
use utf8;
use open qw(:std :utf8);
use Carp;
use HTTP::Tiny;
use JSON::PP;
sub main {
my $response = HTTP::Tiny->new->request(
'POST',
'https://api.metacpan.org/v0/favorite/_search',
{
content => encode_json {
query => {
match_all => {},
},
facets => {
tag => {
terms => {
field => "distribution",
size => 100,
},
},
},
},
},
);
my $data = decode_json($response->{content})->{facets}->{tag}->{terms};
my $i = 1;
foreach my $element (@{$data}) {
say sprintf " %s. [%s](https://metacpan.org/release/%s) — %s",
$i,
$element->{term},
$element->{term},
$element->{count},
;
$i++;
}
}
main();
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment