close $fh
or croak("E: Unable to close file handle for $file: $!");
This usually results in a nice explanation what went wrong.
And, it could be he does so unnecessarily, because it was only the close that failed and not the preceding writes.
This also catched me by surprise. The 'print {$fh}' did return a success, it was only apparent when closing the file handle, that Perl was actually unable to write.
And what can he do about the failures that happen after we've closed the file; due to caching?
Out of scope. As least as far as Perl is concerned. (And I think there is no chance you can truly validate that the data has been written to disk. At least as long as you do not have an exact knowledge about the storage architecture. And even then it may still be lying.) |