note
steves
<p>
Another approach would be to create your new file as a
unique temporary file, then use something like
<a href="http://search.cpan.org/~rbs/Text-Diff-0.35/lib/Text/Diff.pm">
Text::Diff</a> to diff the two files. If they differ, you
remove the old one and rename the new (temporary) one to
the name of the old removed file. If they are the same, you
just remove the temporary file.
</p><p>
I agree about the locking: to do this without race
conditions, you should consider locking the target file.
You may also be able to use file modification times to see
if the file has changed since you started looking at it.
</p>
410351
410368