Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Reset STDERR to console

by sumeetgrover (Monk)
on Apr 01, 2011 at 09:52 UTC ( [id://896837]=note: print w/replies, xml ) Need Help??


in reply to Reset STDERR to console

As you'd know, by default, STDERR points to STDOUT.

After you have manipulated the file, as mentioned in the code above, you can point STDERR back to STDOUT using the following code:
*STDERR = *STDOUT;

Hope this helps!

Sumeet Grover.

Replies are listed 'Best First'.
Re^2: Reset STDERR to console
by moritz (Cardinal) on Apr 01, 2011 at 10:11 UTC
    As you'd know, by default, STDERR points to STDOUT.

    Oh really?

    $ perl -le 'print STDOUT foo' 1>/dev/null $ perl -le 'print STDERR foo' 1>/dev/null foo

    So, not true.

    The solution to the original question involves saving the old STDERR in a variable before reopening it. If I remember correctly, perlopentut talks about that.

      It would have been accurate to say that the IO handles for STDERR and STDOUT are assigned to the same device rather than that one IO handle is assigned to the other.

      One world, one people

        Not really. STDOUT and STDERR default to be the same as the parent's STDOUT and STDERR respectively. There is no relation to devices.
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://896837]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-25 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found