You're right, multiple processes opening a file have no POSIX primitives to atomically modify it file.
However, the vfs layer guarantees that rename() is atomic. This is how things like maildir & IPC::DirQueue do their magic. Unfortunately, this is not useful for you here.
]]>The warning that it's merely advisory is moot here: if you control all the programs writing to this log file, you can modify them to honor that lock.
This lets you avoid a dependency on an additional daemon, but may introduce some contention between your 100s of processes.
Using DBD::SQLite also lets you avoid external dependencies, while letting you store structured data (rather than lines of a Storable image). The SQLite library will handle the locking for you, so your concurrent processes can all write at once.
Are they writing to this log file at high-frequency? Perhaps it'd be easier to let each process have it's own independent log file, and move the complexity to the log consumer to reassemble things into order?
]]>At first glance it looks dangerously easy to believe that write() or print() is atomic. As you are discovering, that is not really the case.
Consider using IPC::DirQueue, which will let you create a queue of data to be processed. it will retain ordering, and uses a directory modification protocol that ensures that things don't get clobbered.
If you want to continue to pursue the log file solution, you may want to consider writing your own logging agent. Have multiple processes connect to a socket (local Unix domain socket) that your logging agent makes available, and the agent will be responsible for reading a complete record, and writing a complete record to the log file, before consuming another one.
]]>http://www.cl.cam.ac.uk/~mgk25/unicode.html
Included in that demo is
http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt
Which is a handy file to have around to test if your terminal is configured for UTF-8, and/or what fonts you are missing. Simply 'cat UTF-8-demo.txt' and you'll see quickly if your setup and good to go.
]]>