Re: non-determinate program execution in perl

From: Nelson Castillo (nelsoneci_at_gmail.com)
Date: 08/31/05

  • Next message: Rodney D. Myers: "Re: [hardware] PCI IDE controller oddity"
    Date: Wed, 31 Aug 2005 16:06:38 -0500
    To: Donald Perkovich <donp@mindspring.com>
    
    

    On 8/30/05, Donald Perkovich <donp@mindspring.com> 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 <http://pop.example.org>',
    > port => 110,
    > user => 'someuser@example.org',
    > pass => 'asswordpay',
    > dir => '/home/user/mail'
    > );
    >
    > Here is Line 40.
    >
    > $server->user($pop{user}) || die;
    >

    This code works just fine:

    -------------------
    #!/usr/bin/perl -w

    use strict;

    my %pop = (
    server => 'pop.example.org <http://pop.example.org>',
    port => 110,
    user => 'someuser@example.org',
    pass => 'asswordpay',
    dir => '/home/user/mail'
    );

    print $pop{user} || die;

    -------------------

    I use Perl often but I'm no expert. So I guess:

    > (1) Is there a better way to initialize the hash?
    No.

    > (2) Could this be a fault in Perl itself?
    I don't think so.

    > (3) Is it something else entirely?

    Maybe the connection to the POP3 server fails once in a while
    and "$server" is "undefined" and it's not pointing to the
    object you think it's pointing to. Try to check the status of the
    POP3 connection before issuing a call to "$server->user".

    In general, you should always check for exceptions after
    trying to establish a network connection.

    Hope it helps,
    Nelson.-

    -- 
    Homepage : http://geocities.com/arhuaco
    The first principle is that you must not fool yourself
    and you are the easiest person to fool.
    -- Richard Feynman.
    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Rodney D. Myers: "Re: [hardware] PCI IDE controller oddity"

    Relevant Pages

    • Re: SBS2003, Outlook 2003, POP3 from client PC
      ... Merv Porter [SBS-MVP] ... Ethernet adapter Server Local Area Connection: ... POP3 on the client - it doesn't :-( ...
      (microsoft.public.backoffice.smallbiz2000)
    • Re: its it possible to use SMTP on this basis
      ... I've been on a Verizon DSL connection for several eyars ... I would love to use SMTP but first of all I am on a dynamic IP it ... >>> The question was in regards to a good third party POP3 ... >> need instant delivery, you don't use POP3. ...
      (microsoft.public.windows.server.sbs)
    • Re: Exchange as only a Public Folder Store
      ... Go back to using the POP3 Connector to automatically download ALL mail ... for your domain into Exchange every 15 minutes (Exchange distributes it to ... your sers Exchange mailboxes for viewing with Outlook) ... your going to need a reliable Internet connection no matter what ...
      (microsoft.public.windows.server.sbs)
    • RE: Backup Dial up connection
      ... Since the POP3 connector problem is ... after the internet connection was properly configured by the CEICW Wizard, ... Microsoft CSS Online Newsgroup Support ...
      (microsoft.public.windows.server.sbs)
    • Re: ICS client and Outlook Express: Unable to download messages ke
      ... briefly as the ICS Host. ... that it has been configured to be the ICS client now, ... POP3 Log started at 11/18/2004 12:00:59 ... unexpectedly terminated the connection. ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)