PDA

View Full Version : Saving/Writing to files


macchisp
03-02-2007, 02:54 PM
Is there a way that not only displaying information to a browser, but to save the information to a file as well?

I am running a CGI script that reads a database and displays it to a browser. Any idea of how to save the information displayed on the screen to a .html file as well?

Thanks.

ess
03-02-2007, 05:40 PM
You can write the output to a file as it is pulled from the database.

if you are not sure about how to write files in Perl..here is a simple tutorial
http://www.pageresource.com/cgirec/ptut16.htm

KevinADC
03-02-2007, 06:41 PM
my $html_stuff = '<h1>hello world</h1>';

open (my $fh, '>' , 'path/to/name.html') or die "$!";
print $fh $html_stuff ;
close $fh;

exactly how you do the printing to the file depends on your current code but that is the jist of it.