use File::Find; finddepth sub { -d $_ and rmdir $_ }, "yourtopoftree";