I am new to Perl programming, so I apologise in advance if this is a dumb question, which it most probably is. I have checked the tutorials and Q and A sections, but I can't find the answer to my question.
What I want to do is modify a Perl CGI script so that the output (a load of html) is written to a file called output.htm rather than to the web browser. The reason for this is that the perl script takes a long time to run (it is doing many queries to a database), and so I want to make it a scheduled cron job.
I have used the following code:
I find that unless I comment out the lines that I have commented out (relating to the header, start_html and end_html), the output won't go to the file. If I do comment the lines out, then obviously the html isn't well formed because the header is missing.#!/usr/bin/perl -w use CGI qw/:standard *table *Tr *td/; require "/home/httpd/cgi-bin/per +l_scripts/syb_handlers.pl"; use Sybase::DBlib; use CGI::Carp qw(fatalsToBrowser); &dbmsghandle ("message_handler"); &dberrhandle ("error_handler"); open(OUTPUTFILE, ">/home/output.htm") or die $!; # print OUTPUTFILE header; # print OUTPUTFILE start_html( -title=>'Title', ); print OUTPUTFILE (loads of lines of html resulting from the database +queries) # print end_html;
Is there an obvious way around this, or do I need to explicitly write the header to the file using a print statement such as the following?
print OUTPUTFILE "<html><head><title> TITLE </title></head>"; print OUTPUTFILE "<body>"; print OUTPUTFILE # all my html here"; print OUTPUTFILE "</body></html>";
In reply to html output to a file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |