Probably a way, but I only could get it done through a Regex:

foreach (@MailData){
   s/\$YourName/$YourName/g;
   print; 
 }

Note: I did away with $MailData and just used the default $_. Then I used a regex to 
get it to replace $YourName with the contents of $YourName.

As in Perl, this is one way.

Wags ;)

-----Original Message-----
From: fred [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 27, 2001 19:03
To: Active Perl
Subject: Using text file as a template


Hi all,
This is probably obvious but my head is sore from banging on the wall...

I want to create a text file with place holders which will be filled
with data and emailed.  Let me give a simple example:

template.txt:<<

Hello $YourName,
Yadee Yadee Yadee

<<end template.txt>>

<<begin code>>
$YourName = "George";
open (FILE,"<template.txt") or die "Can't open file\n$!\n" ;
 @MailData=<FILE> ;
 close (FILE) ;
  foreach  $MailData(@MailData)
   { print("$MailData"); }
<<end code snippet>>
What I want is Hello George
What I get is Hello $YourName
How do get the substitution to happen?

Thanks,
Fred



_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to