Perl: Print on the “display” and also into a file
问题 Is there any way to print both onto the "display" and also into a file at the same time without repeating the print "string" code? What I want to do: if ($ofile) { open (FILE, '>>', "file"); print "Hello" #some code#; #prints on the display and into the file } instead of: if ($ofile) { open (FILE, '>>', "file"); } print "Hello"; if ($ofile) { print FILE "Hello"; } Tried googling but all I found was either or, not both features together. Edit to add questions: Then use IO::Tee to create a new