foreach ("", split(/\//, $path)) { $p .= "$_/"; -d "$comments_dir$p" or mkdir "$comments_dir$p", 0755; }