Software >> Development >> Languages >> Perl >>  How to lock files for exclusive use

open(filehandle,expr) flock(filehandle,2) # 2 = LOCK_EX i.e. exclusive lock # other codes to do # file processing flock(filehandle,8) # 8 = LOCK_UN i.e. release previously requested lock close(filehandle)