in reply to File::Path::rmtree: What am I not grokking?
Here's a (slightly tested) solution:
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); } }
Portable.
Handles pathes with volumes.
Handles absolute paths.
Handles relative paths.
It could be optimized a little.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File::Path::rmtree: What am I not grokking?
by Aristotle (Chancellor) on Nov 02, 2005 at 22:51 UTC |