BjoernD has asked for the wisdom of the Perl Monks concerning the following question:
The script accesses a file called "addresses" where login and POP3 server are stored in the following way: <login> <pop3 server>\n <login> <pop3 server>\n etc. Generally the script does its work as long as login to the server works too. If login fails I get an error message: Use of uninitialized value in numeric eq (==) at /usr/share/perl/5.8.2/Net/POP3.pm line 302, <STDIN> line 1 (#1) The line itself is:#!/usr/bin/perl use strict; use warnings; use diagnostics; use Net::POP3; use Term::ReadKey; # Read the mail accounts from a file called addresses # which resides in the script's directory open ADDRESSES, "./addresses"; # read all the lines my @addys = <ADDRESSES>; # close address file close ADDRESSES; # do the following for every address foreach my $address (@addys) { # chomp newlines chomp $address; # split address into username and hostname (my $user, my $host) = split /\s/, $address; # let the user enter his password print "Please enter the password for $user\@$host\:"; ReadMode( "noecho" ); my $pass = ReadLine(); ReadMode( "normal" ); print "\n"; # connect to host my $pop = Net::POP3->new( $host ) or do { print "Could not initialize connection.\n"; next; }; print "Connected to $host.\n"; # send USER $pop->user( $user ) or do { print "Could not send user name.\n"; next; }; print "Sent username $user.\n"; # send pass, receive number of messages my @a = $pop->pass( $pass ) or do { print "Could not send password.\n"; next; }; # print number of msg or complain about failed login if (defined $a[0]) { $pop->quit(); print "Messages: $a[0]\n"; } else { print "Login failed.\n"; } }
Seems like the problem is that the server after getting the wrong password closes the connection and this way $pop gets undefined? Can anyone please show me a workaround? Thank yousub _QUIT { shift->command('QUIT')->response() == CMD_OK }
20031224 Edit by BazB: Changed title from 'Net::POP3'
|
|---|