I'm trying to process sets of text in a flat file through a perl script and then send them out as emails. The flat file is this sort of format:
|--------------------------------------|
Date: today
Request: text here text here text here
Name: Joe Bloggs
Tel: 0123 45677
email: joebloggs@bloggs.com
|--------------------------------------|
Date: Today
Request: text here text here text here
Name: John Smith
Tel: 0123 45677
email: johnsmith@smith.com
|--------------------------------------|
etc
and I want each set of info sent out to the relevant email address.
I need to separate the sets of data into each request (ie on the '|--------------------------------------|' line) and then run trough the sets of data to print into the email. I tried with the code below but the 'split' doesn't work for finding the end of one request and the start of the next, and then the first line of each request just gets repeated rather than going through them one at a time ie it comes out as:
Today
Today
Today
Today
Today
open(REQUESTS,"/home/picturesea/housekeeping/requestsdeadline3.txt") |
+| die "requestsdeadline3 file not found";<br>
<br>
# Open The Mail Program<br>
open(MAIL,"|$mailprog -t");<br>
<br>
@requests = split(/-|/, <REQUESTS>);<br>
foreach $requests (@requests) {<br>
print MAIL "Bcc: $requests\n";<br>
print MAIL "Subject: PICTURE SEARCH request - deadline expired\n
+\n";<br>
print MAIL "$requests";<br>
print MAIL "$requests";<br>
print MAIL "$requests";<br>
print MAIL "$requests";<br>
}<br>
close(REQUESTS);<br>
can anyone help with this?
thanks
Chris
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.