in reply to Redirect to STDOUT and file

open(STDERR, ">&", \*$TeeErr);

This line doesn't do what you think. I suspect you've got a file named something like IO::Tee=GLOB(0x123456) on your system, with the output you desire.

Something like *STDERR = $TeeErr comes closer to what you want, but isn't perfect.

The surest way to trap and tee all of a program's output is, it seems to me, external: simply run the code piped to a teeing process.

-Mike

Replies are listed 'Best First'.
Re^2: Redirect to STDOUT and file
by ikegami (Patriarch) on Jan 10, 2008 at 05:19 UTC

    open isn't going to create a file (named IO::Tee=GLOB(0x123456) or anything else) when it wasn't asked to create a file. It returns the error "Invalid argument".

      open isn't going to create a file (named IO::Tee=GLOB(0x123456) or anything else) when it wasn't asked to create a file. It returns the error "Invalid argument".

      Not for me under 5.8.8:

      $ ls $ perl -Mstrict -MIO::Tee -le 'my $tee=IO::Tee->new(">/dev/null"); ope +n(FH, ">&", \*$tee)' $ ls IO::Tee=GLOB(0x8802e2c) $ perl -e 'printf "%vd\n", $^V' 5.8.8

        How odd. It shouldn't. I had tested to make sure it didn't before posting. But I forgot to take into consideration that ":" is a special character in my system (Windows) .