use File::Find; finddepth( sub { (-d) ? rmdir : unlink }, $directory);