I am intrigued by how really difficult it is to do "Practical Extract and Report Language" tasks.
This little script extracts the plain text from the body of a users's eMail msg on my server's incoming storage dir and works fine when there is only one message.
The thing needed now is that since each new message is appended to the file in the server < /var/email/ > I need to get the script to extract from the LAST messsage.
How do I instruct the script to find the LAST instance of the text for splitting? Or, can the file be read from the end up? Could all messages but the last one be deleted by the script? (After the first call, there would be only the one message in the file, don't want that deleted until users sends another).
thx,
mike
#!/usr/bin/perl
$filename2 = "/usr/local/etc/httpd/htdocs/dancewithdebbie/email.txt";
$filename = "/var/mail/debbienl";
$redirect = "http://www.dcdancenet.com/dancewithdebbie/news2.shtml";
open(FILE,"$filename");
@lines = <FILE>;
close(FILE);
$start=0;$finish=0;
open(WRITE,">$filename2") || die "Can't open $filename2!\n";
foreach (@lines) {
chomp; #now you can ignore the \n
if ($_ eq "Dance with Debbie") {
$start=1;
}
if ($_ eq "Content-Type: text/html;") {
last;
}
if ($start ==1) {
print WRITE "$_\n"; #add it back in
}
}
close (WRITE);
print "Location: $redirect\n\n";
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.