Printing debug output to another filehandle?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I have an application (actually, it's a co-worker's, but he doesn't do
USENET, so I'm asking for him) that uses Expect extensively.  We like
to be able to view Expect debug output by setting $Expect::Debug.  The
problem is that prints debug output to STDERR, which spews a
huge amount of output, causing our regular debug messages (generated
by utility functions in a module we created more or less for that
purpose) to get lost in the shuffle.

I'd like to be able to redirect Expect's debug output to a file,
without having to redirect STDERR manually-- is there a way to do it?
Offhand, all I can come up with is changing our debug functions to use
$stderr instead of STDERR, and duping STDERR to $stderr when our
utility module is loaded.  That's less than ideal, so if there's a
better way, I'd love to hear it.

Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
        -- Blair Houghton.

Site Timeline