I want my perl program to print to STDOUT on the console, then redirect so that STDOUT goes into a file, then redirect again so that STDOUT goes to the console. I figured out how to redirect to a file, but I can't figure out how to redirect BACK to the console. HELP!
PS: the reason I have to use STDOUT rather than a different file handle is because I want to execute a system() command that will generate output that goes to STDOUT.
PS: the reason I have to use STDOUT rather than a different file handle is because I want to execute a system() command that will generate output that goes to STDOUT.
Code:
print "printing to screen\n";
open(STDOUT, ">file.txt"); # redirects to file
print "redirected to file\n";
# How do I redirect back to screen?
print "back to screen\n";