in reply to A flock()alypse now

I think that your solution may work, but there is simpler solution; as usual the solution is in your manuals.

Take a look at man perlopentut, in section file locking

If you are not doing this for study, there is already a solution on CPAN, one of these is IO::LockedFile