in reply to logging of process
lock is for variables (when using threads). You want flock (or File::Flock, IO::File::flock).