use File::Find; finddepth(sub { rmdir $_ if -d }, $some_path);