sub foo { my($O) = @_; print $O "blah\n"; } foo($to_file ? *MYFILE : *STDOUT);