http://www.perlmonks.org?node_id=594422


in reply to How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?

Untested idea:
  1. Create a subclass of IO::Handle or IO::File with a custom DESTROY subroutine that closes (if open) with error handling.
  2. Use the subclass instead of basic filehandles.