open(STDOUT, "| tee $filename"); # print normally, with output going to the browser and to the file $filename close(STDOUT);