$|=1; my $stdout=''; close STDOUT; open STDOUT, ">", \$stdout; print "this\n"; close STDOUT; open STDOUT, '>-'; print "that\n"; print "[$stdout]";