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

Re: redirect all output

by ihb (Deacon)
on Apr 28, 2005 at 14:35 UTC ( #452309=note: print w/replies, xml ) Need Help??


in reply to redirect all output

You can duplicate STDOUT and then reopen STDOUT to something else.

open my $stdout, '>&STDOUT' or die $!; open STDOUT, '>', $file or die $!;
Now everything printed to STDOUT ends up in the file given by $file. If you want to print to the original STDOUT you can do that by doing print $stdout 'hello';.

See perlopentut for more on this.

ihb

See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-10-21 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (217 votes). Check out past polls.

    Notices?