August 1999 | Perl Hardware Store | Slide #21 |
if (something()) { open F, $FILE or die ...; flock F, LOCK_SH; print while <F>; } else { open F, "> $FILE" or die ...; flock F, LOCK_EX; my $data = qx{some command}; print F $data; }
Oops, it's still wrong
Maybe we can lock the file before we open it? ... Nope
Maybe the writer can open in append mode, lock the file, seek to the beginning, overwrite the contents, then call truncate ... Bah!
Next | Copyright © 1998 M-J. Dominus |