http://www.perlmonks.org?node_id=871574


in reply to Re^2: Generate a unique ID
in thread Generate a unique ID

Problem is, how do you distinguish between failure to create because it exists, and failure to create for some other reason?
You'd look at the error code. If the directory exists, the error will be EEXIST, and if it fails for some other reason, the error will be different.