Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Based in SHARYANTO's script, but adds version numbers to the output.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Data::Dump qw(dump);
use File::Slurp;
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
use JSON;
use LWP::Simple;
my $cachef = "/tmp/allpackages.cache";
my $json = JSON->new->allow_nonref;
my $debug = $ENV{DEBUG};
my $res;
sub dist2deb {
my ($dist) = @_;
die "Usage: $0 <CPANID> ...\n" unless @ARGV;
binmode STDOUT, ":utf8";
my %pkgs;
unless ((-f $cachef) && (-M _) < 7) {
say "DBG: Downloading Debian packages list to $cachef ..." if $debug;
$res = get "";
gunzip(\$res => $cachef) or die "gunzip failed: $GunzipError\n";
for (read_file $cachef) {
next unless /^(lib\S+-perl) \((.+?)\)/;
$pkgs{$1} = $2;
say "DBG: Querying MetaCPAN ..." if $debug;
$res = get "".
$res = $json->decode($res);
die "MetaCPAN timed out" if $res->{timed_out};
my %dists;
for my $hit (@{ $res->{hits}{hits} }) {
my $dist = $hit->{fields}{name};
$dist =~ s/-(\d.+)//;
$dists{$dist} = $1;
for my $dist (sort keys %dists) {
my $pkg = dist2deb($dist);
next unless $pkg ~~ %pkgs;
(my $pkg_ver = $pkgs{$pkg}) =~ s/[-].+//;
"%-40s%15s%15s %s\n",
($pkg_ver eq $dists{$dist} ? ' ' : '!'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.