in reply to Why does File::Temp use sysopen?

Why does File::Temp use sysopen?

Because sysopen lets you use some useful open flags. Afaik, File::Temp uses this to avoid race conditions that would be created trying to emulate the same behavior with a plain open.

Update: Indeed, File::Temp uses the O_EXCL flag by default, which does the following:

In many systems the O_EXCL flag is available for opening files in exclusive mode. This is not locking: exclusiveness means here that if the file already exists, sysopen() fails.

That way it can keep retrying until it gets a file that didn't exist. Doing this with a -e check before using open would cause a race condition.