in reply to check for directory no mather what case (linux)

Just toying around with the possibilites, I don't think you necessarily need opendir or readdir. Using glob() might do the trick, as long as you can get the base (root) of the directory you're checking for, for example:
$dir = "/home/Bob/XXX"; $dir =~ m/(\/.*)\/([^\/]+)\/?$/ and ($base,$dirname) = ($1,$2); mkdir $dir unless scalar grep(m/$dirname/i, glob("$base/*"));
Caveat, depending on the platform the slashes might trip you up (forward or backward), but in general it seems to work when I test it out on my Linux and AIX machines just fine. NOTE: Correction, I had pasted the code from the wrong test script - correct code above now