use CGI; my $q = new CGI; open(SAVE, ">&STDOUT"); open(STDOUT, '/tmp/out.html') or die "Couldn't open out file: !$"; print $q->header, $q->start_html('hello world'), $q->h1('hello world'), $q->end_html; open(STDOUT, ">&SAVE");