Thanks for all the answers. It seems that a solution similar to Maverick's is my best bet -
# print stuff just to the browser
open(TEE, "| tee $filename") || die "Can't open pipe: $!";
select(TEE);
$| = 1;
# print stuff to both file and browser
select(STDOUT);
# print stuff to just the browser