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

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.

Replies are listed 'Best First'.
Re^5: make_path for creating directory tree
by james28909 (Deacon) on Dec 23, 2015 at 16:16 UTC
    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!

        Make sure to read and digest everyone else's great examples too!