How can I use tie() to redirect STDOUT, STDERR only for certain packages?
问题 I need to work with some libraries that unfortunately log diagnostic messages to STDOUT and STDERR. By using tie , I can redirect those writes to a function that captures those. Since I don't want all STDOUT and STDERR output of my programs to be captured thtough the tied handle, I'd like to do this only for certain packages. I have come up with a solution where the actual behavior is determined by looking at caller() as can be seen below, but I have the feeling that there has to be a better