35 lines
631 B
Perl
Executable File
35 lines
631 B
Perl
Executable File
#! /usr/bin/env perl
|
|
|
|
use strict;
|
|
use File::Spec::Functions;
|
|
|
|
my ($p, $max) = @ARGV;
|
|
|
|
my %hits;
|
|
|
|
sub find_dir
|
|
{
|
|
my $m = shift;
|
|
my $dx = catdir(@_);
|
|
my $d = catdir($p, @_);
|
|
if (-f "$d/Control" or -f "$d/obsolete" or -f "$d/broken") {
|
|
$hits{$dx} = 1;
|
|
return;
|
|
}
|
|
return if $m <= 1;
|
|
|
|
opendir (my $dh, $d) || "can't open $d: $!";
|
|
foreach my $sd (readdir($dh)) {
|
|
next if $sd eq '.' or $sd eq '..';
|
|
next if $sd eq '.git' or $sd eq '.svn';
|
|
my $fd = catdir($d, $sd);
|
|
next unless -d $fd;
|
|
find_dir($m - 1, @_, $sd);
|
|
}
|
|
closedir $dh;
|
|
}
|
|
|
|
find_dir($max);
|
|
|
|
print join("\n", sort(keys(%hits))). "\n";
|