open(DATA_IN, ">>$template_data") || print ... ... $_ = ; # No, you can't do this on an output file ... #### my $filename="test.txt"; my $template_data = "unsecure/".$filename; $/ = undef; open( DATA_IN, $template_data ) or die "$!\n"; $_ = ; # read the whole file into $_; close DATA_IN; # now check for patterns in $_ that need to change, # and change them. I'm not clear yet on this part # of the problem... but when this is done, finish with: open( DATA_OUT, ">$template_data.new" ) or die "$!\n"; print DATA_OUT; close DATA_OUT; __END__