Nntp.Perl.Org wrote:
I have had success now using Mail::MboxParser for all my basic mail parsing
needs, like getting subject, from, to.  Now bossman wants me to do more
extensive regex filtering and grabbing weird data in the email body.

I wrote a little test script, shown below.  I am able to get the
"appointment date" data, contained in the message body, that I am looking
for, but only for the first record.  The while loop keeps looping back to
that record.  Also, I cannot get to the next line that has the "comments
section" for each email.  I know this has got to be something stupid I am
not seeing, but after looking at this for so long, everything is starting to
blur together.  Would anyone have any insight as to my mistake?
Thanks, Joan

Not a grave mistake you have just mixed up 'while' and 'if'


#!/usr/bin/perl
use Mail::MboxParser;
my $mb=Mail::MboxParser->new('MyMailbox', decode => 'ALL');

#grab data from the body of the message
  while (my $msg = $mb->next_message) {
  $test = $msg->body($msg->find_body) ;

while (defined($_=$test)) {
if(defined($_=$test)) {   # This will work But it seems pretty useless
                          # Where are u using $_
                          #  If just wanted to check $test do that


if ($test =~ /App:.*Date:\s+(.{0,8})\s+Time:/) {
#looking for appointment data here
print "I see the appointment date is $1", "\n";
} elsif ($test =~ /Comments/) {
while (($test=<>) !~ /(Notification|XEDB)/) {
$comments .= $_;
chop($comments);
$comments .= " ";
print "The comments are", $comments;
}#end while ($test=<>)
}#end elsif
}#end while (defined($_=$test)) {

# There is your endless loop




}#while (my $msg = $mb->next_message)






Hope that helps Ram


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to