How can I get a latest release information from metacpan API?
25 July, 09:33, by tokuhirom, machine translated from Afrikaans
for id: punitan
#! / Usr / bin / perl
use strict;
use warnings;
use utf8;
use 5.010000;
use JSON;
use LWP:: UserAgent;
my $ ua = LWP:: UserAgent-> new ();
my $ rest = $ ua-> post (
"Http://api.metacpan.org/v0/release/_search '
Content => encode_json (
{
size => 20,
from => 0,
sort => [{'date' => {order => "desc"}}]
query => {match_all => {}}
fields => [
QW (author version DOWNLOAD_URL distribution date)
]
}
)
);
$ Rest-> is_success or die "Fail to get the latest information modules". $ Rest-> status_line;
my $ that = JSON:: decode_json ($ rest-> decoded_content);
for my $ row (map {$_->{ areas}} @ {$ that-> {hits} -> {hits}}) {
say "$ row-> {distribution} $ row-> {version} to $ row-> {author} - $ row-> {DOWNLOAD_URL}";
}