Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • You left off a bit:
    ... or die "mkpath: Boom!";
    • Actually you most often don't care whether you could create the directory structure, you care whether it's there after the call. So it's:

      -d $directory or die("Could not create ($directory)");

      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.

      -d $directory and die("Could not remove ($directory)");
      -d $directory or die("Could not create ($direct

      • 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