Use MetaCPAN::Client. I admit that it can be daunting at first as there's a lot to learn, but it works reliably.
Here's an example usage where I dig up all of my latest releases I've published to the CPAN, and their respective current versions:
use warnings;
use strict;
use MetaCPAN::Client;
my $mc = MetaCPAN::Client->new;
my $query = {
all => [
{ author => 'STEVEB' },
{ status => 'latest' },
],
};
my $limit = {
'_source' => [
qw(distribution version)
]
};
my $releases = $mc->release($query, $limit);
while (my $rel = $releases->next){
my $dist = $rel->distribution;
$dist =~ s/-/::/g;
printf("%s is at version %s\n", $dist, $rel->version);
}
Output:
RPi::DAC::MCP4922 is at version 2.3605
RPi::ADC::MCP3008 is at version 2.3604
RPi::BMP180 is at version 2.3604
RPi::Serial is at version 2.3603
WiringPi::API is at version 2.3616
App::RPi::EnvUI is at version 0.30
File::Edit::Portable is at version 1.24
Github::Backup is at version 1.02
RPi::ADC::ADS is at version 1.02
Hook::Output::Tiny is at version 0.05
Logging::Simple is at version 1.04
Test::BrewBuild::Plugin::TestAgainst is at version 0.06
RPi::WiringPi is at version 2.3628
RPi::SPI is at version 2.3608
RPi::StepperMotor is at version 2.3604
RPi::LCD is at version 2.3603
Test::BrewBuild::Plugin::Author is at version 0.03
Async::Event::Interval is at version 1.00
Devel::Trace::Subs is at version 0.22
Bit::Manip is at version 1.04
Bit::Manip::PP is at version 1.07
WWW::ProxyChecker is at version 1.005
Module::CheckDep::Version is at version 0.09
RPi::RTC::DS3231 is at version 0.01
RPi::I2C is at version 2.3606
Mock::Sub is at version 1.09
RPi::HCSR04 is at version 2.3604
FreeRADIUS::Database is at version 0.06
RPi::Pin is at version 2.3606
RPi::DigiPot::MCP4XXXX is at version 2.3604
Devel::Examine::Subs is at version 1.69
RPi::GPIOExpander::MCP23017 is at version 1.00
Wrap::Sub is at version 0.06
Geo::Compass::Variation is at version 1.00
GPSD::Parse is at version 1.02
RPi::Const is at version 1.04
RPi::DHT11 is at version 1.04
RPi::WiringPi::Constant is at version 1.01
App::CopyrightImage is at version 1.01
CGI::Application::Plugin::PageBuilder is at version 1.01
Test::Module::CheckDep::Version is at version 0.03
WWW::FreeProxyListsCom is at version 1.006
Plugin::Simple is at version 1.01
Test::BrewBuild is at version 2.20
The $query is what we're wanting to fetch (the 'latest' releases by me ('STEVEB') (because we're using the release() method), and the $limit limits the amount of data returned (we're only interested in the distribution name and its respective version number).
|