This code lists directories in the current directory, and child folders one level down. I'll leave it to you to make this delete your files ;) (btw, this is pretty much straight out of the black leopard book)
#!/usr/bin/perl -w
use strict;
use Cwd;
sub ScanDirectory{
my ($workdir) = shift;
my ($depth) = shift;
$depth++;
my ($startdir) = &cwd;
chdir($workdir) or die;
opendir(DIR, ".") or die;
my @names = readdir(DIR) or die;
closedir(DIR);
foreach my $name (@names) {
next if ($name eq ".");
next if ($name eq "..");
if (-d $name) {
print &cwd."/".$name."\n";
&ScanDirectory($name, $depth) if $dept
+h <= 1;
next;
}
}
chdir($startdir);
}
&ScanDirectory(".",0);