in reply to Fork novice requests help...

I fail to see the problem with flock. It's easy. However, there might be a way to avoid use of flock.

If you are using log files, you will typically append to the files, instead of overwriting them each time you log something. Modern Unix kernels (I've no idea how non-Unix kernels deal with the problem) will garantee that writes done to files opened for append are atomic. That means that if you are printing small strings (typically strings not exceeding 512, 1024 or 4096 bytes) you will be fine - no clobbering.

However, if that isn't the case, you still need to use flock. But that's really easy. Assume you open the file(s) for append, all you need is:

use Fcntl ':flock'; .... # Code done in every child. open my $fh => ">> /path/to/log/file" or die "Failed to open: $!"; flock $fh => LOCK_EX or die "Failed to lock: $!"; print $fh $your_text; close $fh or die "Failed to close: $!";
That's all there's to it! One use statement, to include the constant LOCK_EX and just one extra statement.

The perlopentut manual should tell you more about flocking. You also might want to look into man perlipc.

-- Abigail