in reply to close on STDERR

Are you attempting to capture all output to STDERR to the file?(including warns and dies) or are you writing out only your own error messages to the STDERR handle(as your code snippet implies)? If you are controlling what is output to the STDERR filehandle through print statements, then there is no reason to use a standard filehandle name and risk conflicts and complexity due to clobbering the existing STDERR. Just call it ERR and be done with it. No fuss, no muss. And yes, it is nice of your to close it when you are done.

HTH