in reply to open for append

You should use syswrite instead of print.

print goes through libc's stdio (or perl's replacement) whereas syswrite is a direct system call. The corruption you are seeing when LOG_FORMAT has length greater than 4K is likely due to buffering by stdio.

The code for append_like_hell using syswrite would be:

sub append_like_hell { my $id = shift; open my $log, '>>', FILE_NAME or die ... for (1..$NUM_LINES) { syswrite($log, sprintf(...)) or die "..."; } close($log); }

Two notes: 1) flushing has no effect here; 2) even though syswrite returns the number of bytes written, because $log is opened to a disk file it will always be either undef or the length of the passed string. In general, to fully write a string using syswrite (e.g. to a socket or a pipe), one has to loop until the entire string has been written (cf. the following from AnyEvent::Worker):

for (my $ofs = 0; $ofs < length $wbuf; ) { $ofs += (my $wr = syswrite $fh, substr $wbuf, $ofs or die "unable to + write results"); }