find( { bydepth => 1, wanted => sub { if (-d $_) { rmdir $_; } else { 1 while unlink $_; } }, }, 'test') if -d 'test'; rmdir 'test';