http://www.perlmonks.org?node_id=604314


in reply to reuse STDOUT after it was closed

Depending on the structure of your code, you could use somehting as simple as localizing STDOUT.
print "Msg to original STDOUT\n"; { local *STDOUT; open(STDOUT, ">my_file") ; select STDOUT; $| = 1; print "msg to Redirected STDOUT\n"; } print "Msg to original STDOUT again\n";
Note that the localized copy of STDOUT will be used by any subs called from within the block (after the local), unlike with "my", but from your post, I think that's what you want. (Localizing STDOUT when you change it is good practice in any case.)