open F, '>outfile.txt' or die "opening output file: $!\n"; open DUPOUT, '>&STDOUT' or die "Can't dup stdout: $!\n"; tie *STDOUT, 'Tie::FileHandle::MultiPlex', *DUPOUT, *F;