in reply to You've got mail!

To avoid the race condition CountZero mentions, maybe try storing the unique ids of all the messages in your mailbox and check for new messages by calling Uidl and comparing the results with what you have stored (I'm not sure if this gets unreasonably slow with a large message queue). Something like:
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