require File::Spec;
my ($vol, $dir, $file) = File::Spec->splitpath($target);
my $base = File::Spec->catpath($vol, $dir, '');
- unless (-e $base) {
+ if (-e $base) {
+ 1 while unlink $target;
+ } else {
require File::Path;
File::Path::mkpath([ $base ]);
- } else {
- 1 while unlink $target;
}
open my $fh, '>', $target