Skip to content
No description or website provided.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Version::Finder::MetaCPAN - Find the appropriate distributions to install to satisfy version requirements using MetaCPAN


version 0.01


use Version::Finder::MetaCPAN;
use CPAN::Meta::Requirements;

my $req = CPAN::Meta::Requirements->new;
$req->add_string_requirement('Moose', '== 2.0401');

my $vf = Version::Finder::MetaCPAN->new;
# Find all the requirements for the Requirements we've defined.
# The Chart::Clicker and 2.0 parts are just for information, the $req
# object is all that matters.
my $results = $vf->build_tree_deps('Chart::Clicker', '2.0', $req);

# Flatten and get the depth
my @items;
$results->traverse(sub {
    my ($_tree) = @_;
    my $info = $_tree->getNodeValue->info;
    push(@items, { depth => $_tree->getDepth, info => $info });

# Sort to find the deepest deps.
my @sorted = reverse sort { $a->{depth} <=> $b->{depth} } @items;

# Print out the tarballs we need
foreach my $item (@sorted) {
    print $item->{info}->{download_url}."\n";


Warning: Version::Finder::MetaCPAN is experimental. It might be broken, return incorrect results or change drastically. Help is welcome!

Version::Finder::MetaCPAN uses the ElasticSearch index that backs MetaCPAN to find the specific releases of distributions that satisfy the requirements defined in a CPAN::Meta::Requirements object.

Calling find creates a search with a series of filters that returns the most recent release of a distribution that satisfies the requirements. It understands all of the restrictions defined by CPAN::Meta::Requirements.


Version::Finder::MetaCPAN is able to answer this question: Given a couple of modules and their requirements, what do I need to fetch from CPAN to get it all working?

my $reqs = CPAN::Meta::Requirements->new;
$reqs->add_minimum('Moose' => '2.0');
$reqs->add_maximum('Graphics::Primitive' => '0.60'); # Maybe 1.0 is incompatible
$reqs->exact_version('Try::Tiny' => '0.11'); # I insist!

my $vf = Version::Finder::MetaCPAN->new;
my $results = $vf->find($results);

foreach my $dep (@{ $results }) {
    print $dep->{download_url}."\n";


find ($requirements)

Given a CPAN::Meta::Requirements object, returns an arrayref of hashrefs that point to the specific releases of each specified distribution.

find_distribution_for_module ('Some::Module')

Find the name of the distribution that provides the module with the specified name.

build_tree_deps ($dist, $ver, $reqs)

Given a dist name, version and CPAN::Meta::Requirements object this method inspects the dependencies recursively and returns a Tree::Simple object representing the recursively resolved dependencies of all modules.


Cory G Watson


This software is copyright (c) 2012 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Something went wrong with that request. Please try again.