in reply to You've got mail!
my %msg_uid_hash = (); ... sub daemon { ... $new_msg_cnt = 0; # check current uid list against our last one my @msg_uid_list = $pop->Uidl(); foreach my $uid (@msg_uid_list) { $new_msg_cnt++ if !$msg_uid_hash{$uid}; } # replace the old uid list with the current one %msg_uid_hash = map {$_ => 1} @msg_uid_list; ... }
Update: actually, using the message count isn't so much a race condition as a flawed model; messages can easily be deleted, making the message count a poor indicator of new messages.
Brad
|
|---|