> On 8/30/05, Donald Perkovich <[EMAIL PROTECTED]> wrote: > > I have a perl program that runs every hour that scans a POP3 maildrop. > About once every other day the program fails and I get this error: > > Can't call method "user" on an undefined value at > /home/user/bin/fetch- headers.pl line 40. > > It appears to me that the hash isn't being properly initialized. > Here is the code that initializes the hash. None of these values > are changed in the program once they are set. > > my %pop = ( > server => 'pop.example.org', > port => 110, > user => '[EMAIL PROTECTED]', > pass => 'asswordpay', > dir => '/home/user/mail' > ); > > Here is Line 40. > > $server->user($pop{user}) || die; > > My questions are: > (1) Is there a better way to initialize the hash? > (2) Could this be a fault in perl itself? > (3) Is it something else entirely? > > Don
Here $server is a perl object, and user() a method with $pop{user} as its argument. From the error message the $server object is not being initialized, and this would be somewhere else in the code, not shown here. If the code works most of the time, the failure is probably due to some problem connecting to the server, but the code (sigh) continues to run past the actual failure and the error message is generated later. Better would be to place some sort of error checking at the point where $server is initialized, and die with a more meaningful message. -- Ken Irving, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]