Vitaliy,

Thank You for your help.

Your solution certainly looks more elegant than mine. I did

    $email_body =~ s/<FirstName>/$firstname/g;
    $email_body =~ s/<date>/$date/g;
    $email_body =~ s/<SelectCity>/$selectCity/g;
    $email_body =~ s/<time>/$time/g;
    $email_body =~ s/<Workshop1>/$workshop1/g;
    $email_body =~ s/<workshop2>/$workshop2/g;

What I would also like to do is preserve those carriage returns that appear
between lines in the text file as well.

Any ideas ?

Thanking you again

Colin

-----Original Message-----
From: vitaliy babiy [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 14 January 2003 8:23 PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]:
Subject: re slurping a text file


  my %var = ('FirstName'=>'John Doe',
                     'time' => '12:12:56',
                     'date' => '2002-12-12');


  $line =~ s{<([^>]+)>} { exists( $var{$1} ) ? $var{$1} : "" }gsex;

"Colin Johnstone" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Gidday all,
>
> I wish to slurp in a letter template in the form of a text file and
> substitute fields in the letter for variables that are input on my html
> form. I indicate in the text file where the substitution should take place
> by the use of a <tag> like in html.
>
> the Text file looks like this
>
> <snip>
> Dear <FirstName>,
>
> Your registration for our workshops has been successfully processed.
>
> Date: <date>
>
> Venue: <SelectCity>
>
> Time: <time>
>
> You have nominated to attend the following two workshops:
>
> <Workshop1>
>
> <workshop2>
>
> We look forward to seeing you.
>
> </snip>
>
> This is then to be sent as an email to the person who registered. I've
done
> the code it is below.
>
> <code>
>
> #!/usr/local/bin/perl
>
> print "Content-Type: text/html\n\n";
>
> $autoResponse = "responsepage.txt";
> $from = "colin\@johnstonefamily.com";
> $to = "colinjohnstone\@ozemail.com.au";
> $subject = "Testing.. Testing..";
> $sendmailpath="/usr/sbin/sendmail";
>
> #$inFile = "c:/xitami/cgi-bin/hp_data/".$autoResponse;
> $inFile =
> "/home/bdweb8083m/johnstonefamily.com/cgi-bin/hp_data/".$autoResponse;
>
> open (SENDMAIL, "| $sendmailpath -t");
> print SENDMAIL "Subject: $subject\n";
> print SENDMAIL "From: $from\n";
> print SENDMAIL "To: $to\n\n";
> print SENDMAIL "This is a test e-mail.\n\n";
>
> $/ = "undef";
> open(IN, "<$inFile") or die("Cannot open: $!");
> while( $email_body = <IN>){
>     print SENDMAIL "$email_body\n\n";
>   }
> close(IN);
>
> print SENDMAIL "Bye!\n\n";
> close (SENDMAIL);
>
> print("sending to...: $to<br>");
>
> </code>
>
> All I need is help substituting the tags for the variables.
>
> Any help appreciated.
>
> Thank You
>
> Colin
>
>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to