Try this (works in some tests I did):
use strict;
use warnings;
sub report($@) {
my $file = shift;
my $temp = "$file.$$";
1 until -w $file;
rename $file, $temp or die "rename [$file] [$temp]: $!";
open my $t, '+<', $temp or die "open [$temp]: $!";
seek $t, 0, 2 or die "seek [$temp]: $!";
print $t @_;
close $t;
rename $temp, $file or die "rename [$temp] [$file]: $!"
}
As the two 'rename' operations are atomic, this might work, and the file inode is preserved, so all should be well. Change the "$file.$$" for other (better) tempfilename if you expect concurrent accesses by the same process or thru the network.
[]s, HTH, Massa (κς,πμ,πλ)