in reply to Unassociated Filehandles and Subroutines
This looks like the job for an object. I think the specific problem of the Bad File Descriptor has already been answered. When you need something like this, where you want to extend the functionality of something (a filehandle here), that screams object to me.