in reply to Race conditions

do you want to have only one process that creates "file.html" ?
Then use IO::File with O_CREAT | O_EXCL and you can remove flock.
Or is there something hidden ?

Btw, it looks to me that proper unlink argument should be $SEMAPHORE.