# unbuffer STDOUT $| = 1; open(TEE, "| tee $filename") || die "Can't open pipe: $!"; # unbuffer output to the pipe. select(TEE); $| = 1; select(STDOUT); print TEE "some stuff that goes both places\n"; print "some stuff that goes to the browser\n"; print TEE "some more stuff that goes places\n";