cpan for open() method says
open() will warn you if you don't close its filehandle explicitly before the program ends. It will also warn if you give it an already open filehandle.
Normal practice if you're writing a bunch of things to the file at once is to open the file, write to it, then close it.
For things like log files, where you'll be writing to it a little at a time for a long time, the usual practice is to open, write, and close each time.
I'm not aware of any general way to test a filehandle for openness (though IO::File may provide one... perldoc it). Normally it's not necessary since the file is only open for a short section of code. But if you needed to, you could always set a flag whenever you open the filehandle, and clear it when you close it.
so create a global $openfile = 0; then when you open the file check for (!$openfile) then set $openfile = 1; and when you close set it to zero again.
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.