in reply to Re: recursive mkdir
in thread recursive mkdir

sub dir_ensure { for (@_) { # handles multiple DIRs my $path = ($_ // die("Dir must be specified")) =~ s!/$!!sr; next if -d $path; # DIR is already there die("Path '$path' already exists and it's not a DIR") if -e _; my $parent = $path =~ m"^(/[^/].*?)/(?!\.{1,2}$)[^/]+$"s ? $1 : die("Invalid path '$path'"); dir_ensure($parent); # ensure parent DIR exists mkdir($path) or die("Failed to create DIR $path $!"); } }

Problems with that code:

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)