sub tee { my ($fh1,@output) = @_; print $fh1 @output; print @output; } open my $fh,">","thefile.txt" or die "horribly"; tee ($fh,"What I wanted to say"); #### use IO::Tee; my $tee = new IO::Tee(\*STDOUT,">thefile.txt"); print $tee "What I wanted to say";