open(STDOUT, '> myfilename.txt'); #reopen STDOUT as a file print "This goes to the file\n";