sub checkDir { my ($path, $perm) = @_; ### Check if output dir exists if (! defined $path) { LOG ("Output path not defined; using temp instead...", 1); $path = '/var/tmp/'; } if (! -d $path) { die LOG ("$path is not a valid directory...", 0); } if (! do { local $_ = $path; $perm->() }) { die LOG ("Test failed on $path, not able to use it.", 0); } LOG ("Using $path as output directory...", 2); }