Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 57 lines (45 sloc) 1.168 kb
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
sub debug { print @_ if $ENV{DEBUG}; }
my $dbh = DBI->connect('dbi:SQLite:dbname=cpants_all.db', undef, undef);
my ($author_id) = $dbh->selectrow_array(
"SELECT id FROM author WHERE pauseid = 'RJBS'",
);
my $dists = $dbh->selectall_arrayref(
"SELECT id, dist FROM dist WHERE author = ?",
undef,
$author_id,
);
my @queue = @$dists;
my %mine = map { $_->[1] => 1 } @queue;
my %seen;
while (my $dist = shift @queue) {
next if $seen{ $dist->[0] };
debug "looking for dists that require $dist->[1]\n";
my $needed_by = $dbh->selectall_arrayref(
"SELECT u.dist, d.dist AS name
FROM uses u
JOIN dist d ON d.id = u.dist
WHERE u.in_dist = ?",
undef,
$dist->[0],
);
for my $needed (@$needed_by) {
next if $seen{ $needed->[0] };
debug " adding $needed->[1] to queue\n";
push @queue, $needed;
}
$seen{ $dist->[0] } = $dist->[1];
}
my $i = 0;
for my $dist (sort values %seen) {
my ($author) = $dbh->selectrow_array(
"SELECT author FROM dist WHERE dist = ?",
undef,
$dist,
);
next if $author == $author_id;
printf "%5u: %s\n", $i++, $dist;
}
Jump to Line
Something went wrong with that request. Please try again.