use File::Path; my $dir = '/to_remove'; rmpath([$dir], 0, 0);