Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Reading from/writing to files with variables substitutions

by 2teez (Priest)
on Mar 28, 2013 at 08:29 UTC ( #1025893=note: print w/ replies, xml ) Need Help??


in reply to Reading from/writing to files with variables substitutions

Hi Oukz,
Really, aitap's wisdom for me is the way to go, however, if I may suggest using here-document like so:

use warnings; use strict; my $first_name = "James"; my $company = "SoftLayer"; my $letter = << "COMPANY_LETTER"; Hello $first_name. I'm writing on behalf of $company .... COMPANY_LETTER 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


Comment on Re: Reading from/writing to files with variables substitutions
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025893]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-04-20 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (488 votes), past polls