Hi all,

I'm fairly new to Perl and am having problems with a hash problem and am getting the response -

"Can't use an undefined value as a HASH reference at line 49"

from my procedure. I am accessing a Notes database (holds telephone directory information) with this procedure included below. The commented out section (used against my mailbox) works fine - but the second section (used against the telephone directory database) gives the error...

If anyone has any hints/can give any help i would be grateful! Thanks,

Lewis Bishop.

PS - the preview of this message looks pretty bad - hope it doesn't come out that way!

use strict; use Win32::OLE; use Data::Dumper; my %count; my $Buffer; my $Document; my $DocCount; my $FullName; my $Extension; my $cnt = 1; my $Notes = Win32::OLE->new('Notes.NotesSession') or die "Cannot start + Lotus Notes Session object.\n"; my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/); print "The current user is $Notes->{UserName}.\n"; print "Running Notes \"$Version\" on \"$Notes->{Platform}\".\n"; $cnt = 0; #------------------this section does work correctly------------------- +---------- #my $Database = $Notes->GetDatabase('GBLOSPK01', 'mail\\lbishop.nsf'); #my $AllDocuments = $Database->AllDocuments; #my $Count = $AllDocuments->Count; #print "There are $DocCount documents in the database.\n"; #for (my $Index = 1 ; $Index <= $Count ; ++$Index) { # my $Document = $AllDocuments->GetNthDocument($Index); # $Subject = $Document->GetFirstItem('Subject')->{Text}; # $From = $Document->GetFirstItem('From')->{Text}; # #$Body = $Document->Body(); # if (index($From,"CN=") > -1) { # $From = substr($From,3); # if (index($From,"/OU=") > -1) { # $From = substr($From,0,index($From,"/OU=")); # } # } # if ($Index < 415) { # print "$Index - From: $From - Subject: $Subject\n"; # #print "BODY: $Body\n"; # } #} #------------------this section does not work correctly--------------- +-------------- my $Database = $Notes->GetDatabase('GBLOSPK02', 'iddnames.nsf'); my $AllDocuments = $Database->AllDocuments; my $Count = $AllDocuments->Count; print "There are $DocCount documents in the database.\n"; for (my $Index = 1 ; $Index <= $Count ; ++$Index) { my $Document = $AllDocuments->GetNthDocument($Index); $FullName = $Document->GetFirstItem('FullName')->{Text}; $Extension = $Document->GetFirstItem('Extension')->{Text}; if ($Index < 145) { print "$FullName - $Extension\n"; } }

Edited 2001-05-16 by mirod: added code and p tags


In reply to Hash problem. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.