Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Answer: how do i redirect STDOUT, STDIN, or STDERR to a FILE?

( #963548=categorized answer: print w/ replies, xml ) Need Help??

Q&A > input and output > how do i redirect STDOUT, STDIN, or STDERR to a FILE? contributed by pwesthagen

Try this, worked for me:
open FILE, ">$file"; select FILE; # print will use FILE instead of STDOUT print "Hello, world!"; # goes to FILE select STDOUT; # back to normal print "Goodbye."; # goes to STDOUT

Comment on Answer: how do i redirect STDOUT, STDIN, or STDERR to a FILE?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2016-02-08 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (286 votes), past polls