| Recursively make directories in perl |
I just whipped up the following function to recursively make directories in perl (much like mkdir -p), and thought I might need it again, so here it is:
sub rmkdir{
my($tpath) = @_;
my($dir, $accum);
foreach $dir (split(/\//, $tpath)){
$accum = "$accum$dir/";
if($dir ne ""){
if(! -d "$accum"){
mkdir $accum;
}
}
}
}
Technorati tags for this post: blog perl mkdir recursive
posted at: 15:16 | path: /diary | permanent link to this entry
Comment on this post.
