use File::Spec (); sub unmkpath { my ($path) = @_; my ($vol, $dirs) = File::Spec->splitpath($path, 1); my @dirs = File::Spec->splitdir($dirs); while (@dirs) { my $dir = File::Spec->catpath($vol, File::Spec->catdir(@dirs), ''); rmdir($dir); pop(@dirs); } }