in reply to logging of process

I cannot use lock($log)

lock is for variables (when using threads). You want flock (or File::Flock, IO::File::flock).