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 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 to the LAST messsage to do the extraction.
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
###
code:
#!/usr/bin/perl
$filename2 = "/usr/local/etc/httpd/htdocs/dancewithdebbie/email.txt";
$filename = "/var/mail/debbienl";
$redirect = "
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";
Before you criticize anyone, walk a mile in their shoes...
That way, when you criticize them, you're a mile away and, you have their shoes
This little script extracts the plain text from the body of a users's eMail msg on my server 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 to the LAST messsage to do the extraction.
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
###
code:
#!/usr/bin/perl
$filename2 = "/usr/local/etc/httpd/htdocs/dancewithdebbie/email.txt";
$filename = "/var/mail/debbienl";
$redirect = "
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";
Before you criticize anyone, walk a mile in their shoes...
That way, when you criticize them, you're a mile away and, you have their shoes