use Errno "EEXIST"; if (! mkdir("foo") && $! != EEXIST) { die "unable to create directory foo: $!" }