in reply to Detecting write errors (disk full, bad media)

As others have pointed out, if print is not successful, the write to the file will not occur. By default, you will probably get no visible messages reporting the failure.

However, if you use warnings, you will probably get a message to STDERR. I can not easily try the case where you have a full disk, but it is simple to try the case where you don't have permissions to write to a file.

If you want to die when a print fails, you would need to add this code:

print $filehandle "CCC\n" or die $!;
Similarly, you could use autodie. UPDATE: As Anon correctly points out below, this can only be used for open/close, not print.

I believe eval should work as you have shown. What happens when you try it?

Replies are listed 'Best First'.
Re^2: Detecting write errors (disk full, bad media)
by Anonymous Monk on Jun 30, 2011 at 15:20 UTC
    autodie does not work with core functions which cannot be overridden

    It will work with open/close, but not print