Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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/\&#39 +\;/\'/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?

In reply to Re: Re: getting text to line break in an email by Anonymous Monk
in thread getting text to line break in an email by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-16 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found