11 &do_mkdir_p($arg); 12} 13 14 15sub do_mkdir_p { 16 local($dir) = @_; 17 18 $dir =~ s|/*\Z(?!\n)||s; 19 20 if (-d $dir) { 21 return; 22 } 23 24 if ($dir =~ m|[^/]/|s) { 25 local($parent) = $dir; 26 $parent =~ s|[^/]*\Z(?!\n)||s; 27 28 do_mkdir_p($parent); 29 } 30 31 mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n"; 32 print "created directory `$dir'\n"; 33}
| 12 &do_mkdir_p($arg); 13} 14 15 16sub do_mkdir_p { 17 local($dir) = @_; 18 19 $dir =~ s|/*\Z(?!\n)||s; 20 21 if (-d $dir) { 22 return; 23 } 24 25 if ($dir =~ m|[^/]/|s) { 26 local($parent) = $dir; 27 $parent =~ s|[^/]*\Z(?!\n)||s; 28 29 do_mkdir_p($parent); 30 } 31 32 mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n"; 33 print "created directory `$dir'\n"; 34}
|