in reply to creating directories

Try File::Path if you are creating more than one directory level at a time.

Update:My mistake. You are obviously NOT creating more than one level, but you might also want to check out File::Spec.

Another update: What's the $! error message from, e.g.:
mkdir($dir) or die "Can't create $dir: $!";