IBM developerWorks runs an excellent article about preventing race conditions – “Secure programmer: Prevent race conditions“. It is written in clean and simple language and explains nicely most common problems with races. It talks about lock files, alternatives to lock files, and doing lock files properly. It features good examples and solutions are described for several languages, including Perl.
This is surely a must read for anyone writing software in general and for multiuser or mutlitasking systems in particular.