in reply to Problems writing to an external file
Code for the template ($Bin/myfilename.TMPL):
Here are my guidelines: <TMPL_VAR NAME=GUIDELINES>
Then here would be the code for your CGI script:
# pre: $guidelines is defined, HTML::Template is installed # in your @INC and you have write privs to $filename use HTML::Template; my $template = HTML::Template->new ( filename => "$Bin/myfilename.TMPL" ); $template->param ( GUIDELINES => $guidelines ); # now you can either print the template to STDOUT or a filehandle # Option #1 (overwriting your .cgi file) open ( TEST, ">$filename" ); print TEST $template->output; close ( TEST ); # Option #2 (printing it to STDOUT - if to a Web browser, # make sure you've already sent the Content-type ahead of # this [next line]). print "Content-type: text/html\n\n"; print $template->output;
My apologies if I read this the wrong way - I just implemented HTML::Template myself and am enjoying it a lot. You will still need to work around your write privs issue if you want to write to a file (the previous responses will help you with that).
Jason
|
|---|