in reply to Hash problem.

As far as the original error goes ("Can't use an undefined value as a HASH reference at line 49"), it looks like your problem is this:

$FullName = $Document->GetFirstItem('FullName')->{Text};

The call to $Document->GetFirstItem() must be returning an undefined value. Why it is doing that is for you to figure out...

Aside from that, I've just got a few general comments. Give the code below, which is a modified copy of what you originally had:

use strict; use Win32::OLE; use Data::Dumper; ### Skipped everything that worked... my ($FullName, $Extension); my $Notes = Win32::OLE->new('Notes.NotesSession)' or die "Can't start Notes session: $!"; ### (1) ### my $Database = $Notes->GetDatabase('GLOSPK2', 'iddnames.nsf'); my $AllDocuments = $Database->AllDocuments(); ### (2) ### my $Count = $AllDocuments->Count; ### (3) ### print "There are $DocCount documents in the database.\n"; ### (4) ### for ( my $Index = 1; $Index < $Count; $Index++ ) { # do stuff... }

I had these observations, suggestions, etc. All of them should be taken with a grain of salt, however, given that I've never done any Lotus Notes programming via Perl.

  1. Will GetDatabase() return an error? Why aren't you checking? (I am not familar with the Win32::OLE module myself, so I briefly scanned this, and did notice that there is a Win32::OLE->LastError() function; however, I'm not sure if you can use that. Just an idea...
  2. Why do you need to maintain a separate count? If $AllDocuments is a list, a hash, a list ref, or a hash ref, you can access the count anytime you need it. E.g., the following expression will return a 'count' if it is a hash ref:
    scalar keys %{ $AllDocuments }
  3. Did you mean $Count instead of $DocCount?
  4. The built-in list/hash iteration capabilities of Perl are nice...I would use them. I notice later in your loop you use GetNthDocument. Why not use GetNextDocument if you can't do something like this:

    foreach my $Document ( each %{ $AllDocuments } ) { ... }

    (I cheated and looked at the Notes docs to find that)

Finally, I'd recommend a closer look at your Notes documentation. I found an example in my Notes docs that "shows how you can use a While loop and GetNextDocument to access every document in a view". You may find that example enlightening.

p.s. -- get a PerlMonks account, log in, stick around... you'll like it here. :-)