I have a main program that could open an error log file.
That program calls a subroutine with the file handle as one of the optional arguments.
What I like to do in the subroutine is as follows:
- If the argument does not exist, use STDOUT as a log file
- If the argument exists, check if the file is open. If it is, use it. If it is not open, then open it (append) and use it.
The problems I have to implement this are essentially:
- How can I check if a file is open?
- Can I have something like:
print $FH, "xxx";
where $FH is either STDOUT or the FileHandle that was passed as an argument?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
That program calls a subroutine with the file handle as one of the optional arguments.
What I like to do in the subroutine is as follows:
- If the argument does not exist, use STDOUT as a log file
- If the argument exists, check if the file is open. If it is, use it. If it is not open, then open it (append) and use it.
The problems I have to implement this are essentially:
- How can I check if a file is open?
- Can I have something like:
print $FH, "xxx";
where $FH is either STDOUT or the FileHandle that was passed as an argument?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]