Thanks for the advice. The script now goes through each email and the regex
gets the Appointment Date properly. I think my last misunderstanding is how
to loop through and get all of the "Comments" in each email, because they
tend to be multi-line. Currently, it keeps looping in an endless loop. I
tried an if statement instead, and I got continuous loops for a while, then
it would hit the next email and do the "Appointment" line, then repeat
comments. If someone could tell me what logical/syntactical error I am
making, I would be much obliged.
Thanks,
Joan
#!/usr/bin/perl
use warnings;
use Mail::MboxParser;
my $mb=Mail::MboxParser->new('huameiMail082003', decode => 'ALL');
#grab data from the body of the message
while (my $msg = $mb->next_message) {
$test = $msg->body($msg->find_body) ;
#I tried $_ = $test; and it worked as well as the for loop
for ($test->as_lines) {
#each line now in $_
if (/App:.*Date:\s+(.{0,8})\s+Time:/) {
print "I see the appointment date is $1", "\n";
}
if (/Comments/) {
#can't figure out how to fix while loop
#also tried if ($_ !~ /(Notification|XEDB)/) {
while ($_ !~ /(Notification|XEDB)/) {
#loop thru each line until you see word "Notification"
#because the comments can be more than one line.
$comments .= $_;
chop($comments);
$comments .= " ";
print "The comments are", $comments;
}#end while
}#end if(/Comments/)
}#end for loop
}#end while (my $msg = $mb->next_message)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]