Just another Perl shrine | |
PerlMonks |
Re^3: How to build system calls using '=>'by serf (Chaplain) |
on Dec 14, 2005 at 15:45 UTC ( [id://516676]=note: print w/replies, xml ) | Need Help?? |
Why: mkpath doesn't require an external binary, doesn't create another process to do its job, and has full control over what it's doing and what comes back - there are less places that the attempt to create a directory can go wrong.
Re remembering: The link to blue_cowdawg's advice in Re: "mkdir -p" equivalent? is there specifically because it *shows* an example of how to use mkpath, including modes etc - so they don't *have* to remember. The 17 line piece of code is an _example_. It is verbose so that the user knows where to report if they need to do so, they can always comment out the print, but it's where it is so they know if they want to report, that's *where* they should do it, i.e. it should only say it's done it once it's worked and not before. Shelling out to 'mkdir -p $path' is OS dependent as well - if you do that on Windows (tested on xp) you will end up with a directory called "-p" as well. In the example it points out *where* to change the directory seperator. mkdir allows you to set the mode as well, if you wish to - fair call, perhaps I could have added that in the example. :o)
In Section
Seekers of Perl Wisdom
|
|