Not using that any more...
OK, so sometimes you decide you're going to stop using some module X, maybe because something better has come along. Let's say I want to track down all my CPAN modules that use Any::Moose because my goal is to port each of them to either Moose or Moo.
MetaCPAN has all the dependency information, but I don't want to click through each of my distributions. Enter the MetaCPAN API...
1: #!/usr/bin/env perl 2: 3: use v5.10; 4: use strict; 5: use warnings; 6: 7: use HTTP::Tiny; 8: use JSON; 9: 10: my @fields = qw< distribution version date >; 11: 12: my ($module, $author) = @ARGV; 13: $module or die "usage: $0 MODULE [AUTHOR]\n"; 14: 15: my $query = { 16: size => 5000, 17: fields => \@fields, 18: query => { match_all => {} }, 19: filter => { 20: and => [ 21: { term => { "release.dependency.module" => $module } }, 22: { term => { "release.status" => "latest"} }, 23: ] 24: } 25: }; 26: 27: push @{$query->{filter}{and}}, { term => { "release.author" => $author } } 28: if $author; 29: 30: my $response = "HTTP::Tiny"->new->post( 31: "http://api.metacpan.org/v0/release/_search" => { 32: content => to_json($query), 33: headers => { 34: "Content-Type" => "application/json", 35: }, 36: }, 37: ); 38: 39: my $result = from_json($response->{content}); 40: 41: for my $dist (@{ $result->{hits}{hits} }) { 42: printf("%s\t%s\t%s\n", map $dist->{fields}{$_}, @fields); 43: }
Maybe you'd like to add this script to the
MetaCPAN::Clients which is just a bunch of scripts. If yes, please send a pull request.