in reply to Reading from/writing to files with variables substitutions
Really, aitap's wisdom for me is the way to go, however, if I may suggest using here-document like so:
my $first_name = "James";
my $company = "SoftLayer";
my $letter = << "COMPANY_LETTER";
I'm writing on behalf of $company ....
my $outfile = "new.txt";
open my $fh, '>', $outfile or die "Can't open file: $!";
print $fh $letter;
close $fh or die "can't close file: $!";
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me