in reply to make_path for creating directory tree

"Is this somehow doable with make_path?"

You're using Perl, so ofcourse its doable!

I would make all the base directories, push the dir name to an array, then foreach "cwd/$dir" make the sub directories how you see fit. Seems pretty much straight forward. Good Luck!

EDIT: Maybe this will give you an idea. ;)
use strict; use warnings; use File::Path qw(make_path); make_path("one/two/three", "four/five/six" , {verbose => 1});
OUTPUT: C:\Perlmonks>make_paths.pl mkdir one mkdir one/two mkdir one/two/three mkdir four mkdir four/five mkdir four/five/six

Replies are listed 'Best First'.
Re^2: make_path for creating directory tree
by fasoli (Beadle) on Dec 23, 2015 at 15:28 UTC

    Thank you for your answer, good to hear that Perl can handle it :)

    Ok so I just tried to use make_path and I did something wrong.

    #/bin/perl/ use strict; use warnings; use File::Path qw(make_path); make_path("~/folder1/folder2/folder3/folder4");

    This creates the following directories: ~ (!!!), then folder1, then folder2, then folder3 and then folder4. If I use single quotes it just exits quietly without an error but without creating anything either. Any thoughts???

    EDIT: Sorry, we posted simultaneously! I'll study your example and retry.

      You're on linux? Im booted into windows, but anyway, are you trying to build directories in /home? If so try "/home/folder1/folder2/folder3/folder4" im pretty sure that you would need to use native 'mkdir' command to use '~/'

      EDIT: Use '~/' like this: 'mkdir -p ~/one/two/three'. I do not see any references to File::Path supporting or NOT supporting '~/'. So maybe someone else can chime in about this. :)

        Yes, I'm on Linux. Sorry, this is really embarrassing but I'm still not using the command properly, dear me :( Now I did

        #/bin/perl/ use strict; use warnings; use File::Path qw(make_path); make_path("/one/two");

        In order to test for now, I try to create the path /one/two just in the current directory but I get the error "mkdir /one: Permission denied at test.pl line 8"

        Embarrassing :( What's happening? Do I need to specify the full path to the working directory, and use the command as make_path("/full/path/to/current/directory/one/two")? It's a bit scary as I'm worried this will delete a file accidentally or something catastrophic like that.