okay, first I put the text block from a database into a text file (requests.txt) and replace the html break tags with '\n'
cat $HOME/housekeeping/requests.txt | sed -e 's/<br>/\\n/g' -e s/\'
+\;/\'/g > $HOME/housekeeping/requests2.txt
this gives me a text file containing for example:
Date : 2001-09-26 10:47:00
Request No. 107
Request Title: CHILDREN
Request : 1. 13 year old twin boys\n2. A boy aged 13 years old standing
facing the camera\n3. A girl aged 13 years old standing facing the camera\n4.
A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower,
Paris\n5. A girl aged approx 11 years old on a beach in Greece(or could be anot
her location as long as it is not too exotic)
Format :
Deadline : 2001-9-27
Budget : £85 per pic used
Name : Louise Edgeworth
Company : Pearson Education
Country : United Kingdom
Telephone : 01279 793472
Fax : 01279 793472
Email : edgeworthl@aol.com
Then I run the perl script and use this code to format the email:
open(REQUESTS,"/home/picturesea/housekeeping/requests3.txt") || di
+e "requests3 file not found";
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "Bcc: $emails\n";
print MAIL "From: chrisbarton\@postmaster.co.uk (PICTURE SEARCH)\n
+";
print MAIL "Subject: PICTURE SEARCH REQUESTS $date\n\n";
print MAIL "If you think you have suitable images, please CONTACT
+THE RESEARCHER DIRECT.\n YOU DO NOT NEED TO REPLY TO THIS EMAIL.\n";
print MAIL "$date\n";
print MAIL "-" x 75 . "\n";
while ($requests = <REQUESTS>) {
print MAIL "$requests";
}
close(REQUESTS);
this all works fine and the email is formatted fine, except the request text comes out:
Request : 1. 13 year old twin boys\n2. A boy aged 13 years old standing
facing the camera\n3. A girl aged 13 years old standing facing the camera\n4.
A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower,
Paris\n5. A girl aged approx 11 years old on a beach in Greece(or could be anot
her location as long as it is not too exotic)
when what I want is:
Request : 1. 13 year old twin boys
2. A boy aged 13 years old standing facing the camera
3. A girl aged 13 years old standing facing the camera
4. A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower, Paris
5. A girl aged approx 11 years old on a beach in Greece(or could be another location as long as it is not too exotic
ie the '\n's don't get translated as line breaks - any idea why this is?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.