jdavidb (email not shown publicly)
http://voiceofjohn.blogspot.com/
J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.
Misnamed (Score:2)
On that note, I submit that File::Path is misnamed. The summary of the module is given as "create or remove directory trees." In other words, it's mkdir -p and rm -rf in Perl.
Convenient to have, hard to find.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:Misnamed (Score:2)
Anyway, it's another handy core module that people don't notice because of the name, sigh.
Omission (Score:2)
Re:Omission (Score:1)
Conversely, if you actually want to create the directory, often the real intent is to make sure it's newly created. So delete it first, then create it.
Re:Omission (Score:2)
In the case of rmtree, perhaps the test should be -e, not -d. I believe your test would fail if the file existed and was not a directory. (Could be wrong.)
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:Omission (Score:2)
The reason I did not do this is it doesn't work. mkpath returns a list of the directories created, not a success or failure. And if you run the program a second time, you get back an empty list (false) because the directory is already created.
I like jplindstrom's approach, although in my case I immediately execute a chdir or die, which has more or less the same effect.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers