in reply to Problems writing to an external file

Trying to understand your purpose and I believe you may want to check out the HTML::Template module from CPAN. With it, you can create a "surround" (or template) file and pinpoint exactly where you want your $guidelines to go and then write the merged file where-ever you want. It looks like that's where you want to go since you're also reading in the filename, but not doing anything with it (yet). :)

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