Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.