in reply to Redirecting STDERR to a variable

In 5.8.0, you can open file handles to "in memory" files. To open (in read-write mode) STDERR of the current script into a scalar of the same script, do this:
my $stderr; close STDERR; open STDERR, '+<', \$stderr or die $!;

Replies are listed 'Best First'.
Re: Re: Redirecting STDERR to a variable
by nimdokk (Vicar) on Sep 12, 2003 at 00:02 UTC
    Interesting, I might have to play with that, might solve a tiny problem I've got at work. Does it work the same for STDOUT as well?


    "Ex libris un peut de tout"
        Many thanks, I haven't dabbled with 5.8.0 (or 5.8.1) much apart from porting my Unix Perl prog's (written under 5.004). But we will be standardizing to a consistent version on both Windows and Unix in the (hoefully) near future.


        "Ex libris un peut de tout"