Since you are making two OLE calls every time you use
$Document->GetFirstItem('From')->{Text}, a more efficient version might be:

if (defined (my $From = $Document->GetFirstItem('From')->{Text})) {

  # do something with $From

} else {

  print "Nothing in the Inbox.  No need to go any farther!  Goodbye!\n";
  exit 0;

}

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-----Original Message-----
From: James E Keenan [mailto:jkeen@;concentric.net]
Sent: Sunday, October 20, 2002 8:28 AM
To: [EMAIL PROTECTED]
Subject: Re: How can I avoid the Undefined reference in a hash value
error


On Fri, 18 Oct 2002 17:01:51 -0400, "Chris Benco"
<[EMAIL PROTECTED]>
wrote with regard to:  How can I avoid the Undefined reference in a hash
value error:

>
> Script seems to work well.  I can send it blank fields and it recovers
> every time.  Problem is when I leave it running it crashes with the now
> infamous Can't use an undefined value as a hash reference At line 16.
When
> it does this there is nothing in the inbox to process.  I added 'or ()' to
> get around this problem, which seems to work when I send it blank fields.
> What else can I do to avoid this problem?
>
> ################################################
>
> use strict;
> use diagnostics;
> use Win32::OLE;
>
> my $userid = "xxx";
> my $server = "xxx/xxx/xxx";
> my $Notes = Win32::OLE->new('Notes.NotesSession');
> my $Database = $Notes->GetDatabase("$server", "mail\\$userid.nsf");
>
> while (1) {
>     my $t = (localtime);
>     print "$t\n";
>     sleep 1;
>     my $AllDocuments = $Database->AllDocuments or next;
>     my $Document = $AllDocuments->GetFirstDocument or next;
>     my $From = $Document->GetFirstItem('From')->{Text} or ();     #  This
is the line it's crashing on
>

I don't know the Win32::OLe module, so I may be off the mark, but why not
something simple at this point like:

      if (! defined $Document->GetFirstItem('From')->{Text}) {
          print "Nothing in the Inbox.  No need to go any farther!  Goodbye!
\n";
          exit 0;
      } else {
          my $From = $Document->GetFirstItem('From')->{Text};
      }


Jim Keenan


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to