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;
          }
        }
      }
    }
    

[tags: perl mkdir recursive]