in reply to Bad file descriptor when trying to close file handle

Notice that after you die, you try to execute that block of code an additional time. ("Can't use an undefined value ... at ... line 480.") That means you try to close the file handle more than once.

We know you try to close the file handle twice. Or rather, at least twice. I suspect there are actually three attempts. Specifically, I suspect you've tried one once before the attempt that died, and that the first attempt was successful.

  • Comment on Re: Bad file descriptor when trying to close file handle

Replies are listed 'Best First'.
Re^2: Bad file descriptor when trying to close file handle
by fireblood (Scribe) on Mar 04, 2022 at 20:13 UTC
    Hi, I read your post several times, focusing on your comment "Notice that after you die, you try to execute that block of code an additional time.". I could not see what you were referring to -- after I die, there are no more instructions. And "die" terminates the execution of the program anyway, so I'm not clear as to how after dying I could possibly try to execute that block of code an additional time. When the die instruction is in fact executed when the invoker calls this module a second time, the program totally stops running. Where would I notice that after I die I try to execute that block of code an additional time? I'm drawing a blank on it. Thanks much.

      I could not see what you were referring to -- after I die, there are no more instructions.

      You have Can't use an undefined value as a symbol reference at /u1/stat/global/bin/perllib/master_log.pm line 480. after Died at /u1/stat/global/bin/perllib/master_log.pm line 494.

      I'm not clear as to how after dying I could possibly try to execute that block of code an additional time.

      Neither are we, since you didn't show us. Maybe you catch the exception? Maybe you call it from a destructor or END block?