Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to check number of messages using Net::POP3?

by duct_tape (Hermit)
on Dec 23, 2003 at 22:36 UTC ( #316731=note: print w/replies, xml ) Need Help??


in reply to How to check number of messages using Net::POP3?

Hello

It looks like response returns undef when it can not getline. I am assume the reason is that your POP3 server is disconnecting you once you enter a bad password. Not quite sure how to get around the warning other than patch Net::POP3 to handle that more gracefully. You can always disable warnings / diagnostics if the warning really bothers you. It's not always worthwhile to jump through hoops to avoid warnings.

Also, here are a few things I noticed when I looked at your code.

According to the documentation for Net::POP3, pass returns the number of messages in the mailbox. Since it returns a scalar you don't need to assign it to an array. You can do something like so:

my $count = $pop->pass($pass);

Also, if there are 0 messages in the mailbox pass will return 0E0 which will evaluate to true. Because of this you can bypass your check for defined as if it returned undef then you would've already caught it with your or do {....

print "Messages: $count\n";

Overall everything looks good! Keep up the good work!

Regards
Brad

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://316731]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2019-10-18 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?