File locking can be achieved using the flock() function. This can be used to guard against race conditions or other problems which occur when two (or more) users open the same file in read/write mode.
flock() is documented on page 166 of the Camel book, or use perldoc -f flock to read the online documentation.