#!/usr/bin/perl
use File::Basename;
$base = $ARGV[0];
open( F, '<', '.dist' ) or die "Could not open .dist";
while( <F> )
{
chomp;
$f = "$base/$_";
unlink $f;
$dirs{dirname($f)}++;
}
foreach ( sort { length($b) <=> length($a) } keys %dirs )
{
while( rmdir )
{
$_ = dirname( $_ );
}
}