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).


In reply to Re: Post query to Metacpan API by stevieb
in thread Post query to Metacpan API by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.