If the filehandle isn't open, then closing it throws a warning. This could happen if the application blows up before the logging ever starts. So to avoid the warning, we check if the filehandle is open before trying to close. Scalar::Util::openhandle seems to be best way to do this. Using tell() throws the same warning, and fileno() doesn't always give the right answer.
If the filehandle isn't open, then closing it throws a warning. This could happen if the application blows up before the logging ever starts. So to avoid the warning, we check if the filehandle is open before trying to close. Scalar::Util::openhandle seems to be best way to do this. Using tell() throws the same warning, and fileno() doesn't always give the right answer.