Situation:  My perl script (see Code: below) is being
handed a flatfile (see File: below) generated from a
database to do a mass mailing that will send a message
generic to the flatfile but with each recepient
receiving a unique username and password.
The message part of the file is being input by a list
administrator through an oracle tool (I think, I
didn't develop that in anyway) and the ability to have
newlines is necessary for formatting.  The problem is
when this message is dumped into the flatfile, the
newlines are still in it and cause the script to go
nuts.

My idea was to have the newlines in the message
replaced with \\n before being put into the flatfile
(which is what I have done in my test file).  I then
attempt to replace the \\n with \n in the $message
field for sending.

It kind of works. (see Output: below) I get the
newlines now, but i also get one \ just out there.  I
have tried many variations, but having \\n and
replacing with \n seems to be the only way to get a
newline to work, but how to get rid of the extra \?

Any suggestions would be very very appreciated.
TIA

Code:
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail -t';
$admin_email="decoraw\@act.org";
$subject="Testing the new mass mailer";
$file =
"/actapps/suitespot/cgi-bin/sender/returntest3.txt";
$number_sent = 0;
open(DATA, "$file") || die "Can't open $file";  # open
the file for reading

while($line = <DATA>)
{
        chomp $line;
        ($junk,$email,$message,$survey_url,$login,$password)
= split(/\|/,$line);
        
        $message =~ s|\\n|\n|g;  #replace the escaped
newlines with newlines for formatting
        
        open (MAIL, "|$mailprog -t") || die "Can't open
$mailprog! \n";
                print MAIL "Content-type:text/plain\n";
                print MAIL "From: $admin_email\n";
                print MAIL "To: $email\n";
                print MAIL "Subject: $subject\n";
                print MAIL "$message\n\n";
                print MAIL "URL: $survey_url\n";
                print MAIL "Login: $login\n";
                print MAIL "Password: $password\n";
                close(MAIL);
                $number_sent++;
}


File:
|[EMAIL PROTECTED]|This is my message.\\nI hope
these returns will work this
time.\\nWendy|http://www.mysite.com/index.html|3|3|

Output:
This is my message.\
I hope these returns will work this time.\
Wendy

URL: http://www.mysite.com/index.html Login: 3
Password: 3




=====
Wendy
Webmistress

My computer has an Emmy, how 'bout yours?

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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

Reply via email to