For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > December 2004 > output HTML to a file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author output HTML to a file
google@taxandfinance.com

2004-12-22, 3:55 am

Short story: Is there a way I can save a copy of my CGI output (the
actual HTML anyway) to use for sending a multi-part MIME message?


I am using CGI.pm and HTML::Template to present a user with a form for
submitting/viewing service requests, including the ability to attach
files. I've got that much working.

Now I need to generate a multi-part MIME message which will include the
same HTML that is returned to the client, in addition to any
attachments. I'm using MIME::Tools do to this and I've created a
SendMail function which is passed, among other things, an array refence
containing a list of files to attach and a string containing the HTML
body of the multi-part message. I don't know how I'm going to create
the HTML body though.

I had originally planned on using LWP::UserAgent to request the same
page from within the CGI script, passing the response->contents to the
SendMail function to be included as the body of the multi-part MIME
message. It's more complicated than I hoped because it uses
SSL,sessions,cookies,etc. Is there an easier way to do this using
functionality provided by CGI.pm or HTML::Template? I need to somehow
be able to save a copy of the CGI output.

Thanks,
Matt

google@taxandfinance.com

2004-12-22, 3:55 pm

I think I'm on the right track. Using HTML::Template I can do this:

my $body="/tmp/body.html";
open(BODY,">$body") || die "Unable to create body of email.\nPlease
contact system administrator\n";
print $template->output(print_to => *BODY);
close BODY;

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com