in reply to Re^2: make_path for creating directory tree
in thread make_path for creating directory tree

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. :)

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

    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.

      You're trying to create folders in root '/' and dont have proper permission. Try make_path("one/two/three"); or make_path("./one/two/three");

      EDIT: Also, you can test if a dir exists before creating it.
      next if (-d $dir); #will skip to next dir IF target dir exists make_path("one/two/three");

        Ugh I'm an idiot. Yes, I was indeed trying to create a folder in root, I corrected that now. Ok first step - use make_path once successfully: done!