in reply to html output to a file
The completely easy way is to reopen STDOUT to your file:
my $outfile = "/home/output.htm"; open STDOUT, ">", $outfile or die "Couldn't write to '$outfile': $!"; ... rest of the program
Of course, if your CGI expects some of the CGI specific variables you might need to fake them. If your CGI outputs a status code, you might want to comment that out from your CGI or just munge the created file afterwards.
This trick works because
print "Hello World"
is secretly
print STDOUT "Hello World";
|
|---|