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

Reply via email to