A cursory strace perl -pi reveals a more sloppy pattern than described, however. I see open/unlink/open/read+write/close/close. The unlinked source file is still readable; it gets released upon close.
A relatively safe update sequence is: mkstemp/read+write/fsync/rename. The final rename is atomic, but that itself does not prevent races with multiple updaters (of course).
In reply to Re^3: read file line by line then do something and write to same file
by oiskuu
in thread read file line by line then do something and write to same file
by john.tm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |