in reply to Redirecting STDIN / STDOUT after fork
or open with the mode '&' (from the cookbook)$variable=*FILEHANDLE; print $variable "things to be printed\n";
Or use local as gloom suggested.open(OLD_OUT,">&STDOUT"); #save curent STDOUT to OLD_OUT open(STDOUT,">/tmp/file.out"); #reassign STDOUT to /tmp/file.out close STDOUT ; open(STDOUT,">&OLD_OUT"); #restore the previous STDOUT
|
|---|