I writed an article for The Perl Journal! To appear in the next issue. It's called "Resource Locking Over Networks", an action-packed sequel to my "Resource Locking with Semaphore Files". So if you want to read it, subscribe and wait for it to come in the mail! Or email me and ask me really really nicely.
«So let's use a concrete example here, such as should be familiar to all our readers. You're the Chief Technical Officer for XAOS, the worldwide consortium of supervillians. Among your many evil duties are coordinating the exchange of the staff phone number directory, phone.tsv. In an ideally evil world, you would have all the evil resources you'd need to build a solid network. But for years now, all available funds have been diverted to the construction of the giant orbiting death-ray, leaving you with only a ramshackle mess of legacy systems.
Notably, the chief of Henchman Resources, Generalissima Mok, personally updates the phone directory on a daily basis, as old staff are killed for their incompetence and others are promoted. She has learned to do this using FileMaker on an old Apple laptop running MacOS 7. You once meekly suggested that she use a web interface for maintaining the phone database, and the Generalissima reacted by torturing you with electric shocks until you promised to forget the whole idea.
She did, however, let you write and install a MacPerl program on her laptop to ftp the phone.tsv file from her Mac to the main server, and she dutifully runs the program after every evil update to the database. The meat of that program looks like this:
But the problem you quickly run into is that others might be downloading phone.tsv from the server just as she's uploading it, resulting in them getting a file that's truncated or garbled. This upsets people, since if they fail to find some friend's name in the phone directory, they assume he has been killed for incompetence. This leads to a tense work environment. You solve the problem of unnerving partial transfers by using a lock directory, like so: [...] »