open LCK, "$file.lck"; flock(LCK, LOCK_EX); # operate on how ever many files here flock(LCK, LOCK_UN); close LCK;