I am using mkdir to create a directory:
$dir_name = "/path/$scalar";
mkdir $dir_name, 0777 unless -d $dir_name;
On occasions this created false directories on the occasions that $scalar wasn't available. I used a conditional to prevent this:
if ($scalar) {
$dir_name = "/path/$scalar";
mkdir $dir_name, 0777 unless -d $dir_name;
} else { die "Sorry, no scalar value available: $!"
}
However I see that phantom directories are still being created (with the name $scalar). On trying to open the directories I get "server response: no such file".
How can I prevent this happening an what can I do to remove these 'phantom' files?