nisha has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks, I have a problem here; i use notes api's inorder to access certain properties of documents in lotus notes. As given in the code below, GetItemValue("PostedDate") is expected to return the value of the PostedDate field in the document. GetItemValue() function returns an array.
#!/usr/bin/perl use Win32::OLE; $server = $ARGV[0]; my $notes_dead = Win32::OLE->new('Notes.NotesSession') or die "Cannot +open Notes Session, $!"; print "The notes_server is : $server \n"; my $database_dead = $notes_dead->GetDatabase( $server,'mail\\admin.nsf +' ); my $view_dead = $database_dead->GetView('$Inbox'); my $ndoc_dead = $view_dead->GetFirstDocument; while ( $ndoc_dead ) { $nDocCount +=1; my $sub = $ndoc_dead->GetFirstItem("Subject"); my $deadlocation = $sub->text; #print $ndoc_dead->GetFirstItem("PostedDate"); my @Postdate = $ndoc_dead->GetItemValue("PostedDate"); print @Postdate , "\n"; foreach $i (@Postdate) { print @$i , "\n"; } $ndoc_dead = $view_dead->GetNextDocument($ndoc_dead); }
The value is collected in a variable @Postdate, printing only @Postdate returns a values like this ARRAY(0x422f2d8. In order to dereference it i tried to access every item in the array and used @$i; on printing this the value that got printed is Win32::OLE::Variant=SCALAR(0x422f4b8). Another observation that was made is this was seen only in case where the return value is in date format. if in place of PostedDate, Subject field was specified which is a string, i was able to print the value of subject field correctly using the same program. Please let me know if i am missing out on something. Thanks, Nisha

Replies are listed 'Best First'.
Re: Problem with references
by Polonius (Friar) on May 11, 2006 at 09:47 UTC

    nisha,

    I'm new to Perl myself, so I'm probably wrong, but here goes.

    Data::Dumper should allow you to print the entire contents of @Postdate, so you can see what's going on.

    HTH,

    Polonius
Re: Problem with references
by Errto (Vicar) on May 12, 2006 at 00:41 UTC
    As I recall (no Win32 box to test on), to turn a variant into a normal Perl value, you need to use one of the methods in Win32::OLE::Variant. In your example it looks like the Date method might be the appropriate one, though for starters you can try just Value to see what it says.