&checkDir('/usr/tmp', '-w'); #or... &checkDir('/usr/tmp', '-r') sub checkDir { my ($dir, $perm) = @_; ### Check if output dir exists if (! defined $path) { LOG ("The path where to save the output is not defined using temp instead...", 1); $path = '/var/tmp/'; } if (! -d $path) { die LOG ("$path is not a valid directory...", 0); } if (! $perm $path) { die LOG ("You do not have $perm to $path directory...", 0); } LOG ("Using $path as output directory...", 2); }