good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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:
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):
In reply to Re: open for append
by perl5ever
|
|