in reply to forgoing explicit file close

It is horrible if you want to test for errors when writing to a file. Some errors may not show up until you close the file, due to buffering. E.g.:
open my $fh, ">/dev/full" or die "open: $!\n"; print $fh "abc\n" or die "print: $!\n"; close $fh or die "close: $!\n";
which outputs:
close: No space left on device

Dave.

Replies are listed 'Best First'.
Re^2: forgoing explicit file close
by BrowserUk (Patriarch) on Aug 22, 2015 at 09:05 UTC
      Would it be beyond the realms of possibility for that warning to be produced when a filehandle goes out of scope?
      It's a default warning in 5.22.0 onwards:
      $ perl5220 -e'{open my $fh, ">/dev/full"; print $fh "abc"}' Warning: unable to close filehandle $fh properly: No space left on dev +ice at -e line 1. $

      Dave.