if ($query{submit} eq "PDF") { open STDOUT, ">tempfile.html" or graceful_exit("can't open file"); }