open STDOUT, ">$tempfile"; #do some stuff here close STDOUT;