use Fcntl qw(:flock); flock($OUT, LOCK_EX) or scriptAbbruch("Lock kann nicht erzeugt werden");