$lockOK = flock($filehandle,2); # Resumes program flow when you obtained the lock # or $lockOK = flock($filehandle,6); # Check return value to see if you were able to lock the file # ..... flock($filehandle,8); # Release lock when done