Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by duct_tape (Hermit)
on Dec 23, 2003 at 22:36 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316731]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 01:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found