http://www.perlmonks.org?node_id=798291


in reply to Avoid multiple process writing to a file at the same time

Please read perldoc perlfaq5