open DATAFILE, "+< $datafile" or die ...; flock DATAFILE, LOCK_EX; read and modify the data file here... flock DATAFILE, LOCK_UN;