http://www.perlmonks.org?node_id=430250

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

Hello Monks,
I'm trying to download a Lotus Notes database from a server. Thererfore I found the excellent program here. With this program I'm able to download all the files from this database.

My problem now is, that the database is build like this: database -> folder -> subfolder1 -> subfolder2 -> files
and if I just download it then it is stored like this: \Notes2Files\folder\all_the_files but if possible I would like to have it in the same style as the database is build itself, including the subfolders.
And I'd also like to download only particular folders

# Loop over all of the folders foreach my $viewname (GetViews($database)) { # Continue only for one folder if ($viewname eq "folder") { # Get the object for this View print "Saving Messages in folder $viewname..."; my $view = $database->GetView($viewname);
... what can be easily done with the "if - question".

Now my idea was to insert another "foreach" loop after this "if - question" to check for the next sublevel of my database. Unfortunately a simple  foreach my $subview (GetViews ($viewname)) creates an error like:  Can't use string ("$viewname") as a HASH ref while "strict refs" in use at test.pl line XX.
I looked at the value that $database contains at the first loop, but Win32::OLE=HASH(0x1978a3c) doesn't really help me. So, I don't understand in the moment how I can deal with this problem or what I have to do to make to program rum.

Maybe someone can help me out with a good idea or simpely the syntax of the "foreach" loop ;-)

Thank you very much in advance

Tobi

I'm using Perl v.5.8.4 under WinXP with Lotus Notes 5.0.11

Replies are listed 'Best First'.
Re: Downloading from a Lotus Notes database
by sandfly (Beadle) on Feb 11, 2005 at 22:42 UTC
    $database is a Win32::OLE object. $viewname is a string. The GetViews sub is expecting an object.

    The Win32::OLE objects all seem to work the same way - they are hash references. Methods are implemented as perl methods, and properties are implemented as hash elements.

    If you look at the GetViews sub in the sample script, you'll see it expects its parameter to be a hash reference (really, an OLE object) containing a Views key (i.e. property), and the value is an array reference to a list of hash references (Notes View objects). Each of these has a Name key (property) with a string value. The sub returns this list of strings

    So by passing the folder string to GetViews, you're asking it to do "folder"->{Views}. This is the error.

    I don't know the Notes object model, but I suggest you modify GetViews so it returns the view objects themselves, instead of the names. It's quite likely you will be able to call back into GetViews with a view object as a parameter.

    On a general note, the ActiveState distribution contains a very useful OLE browser, which lists the the OLE APIs on your PC, and the objects, properties, methods and events they implement.

Re: Downloading from a Lotus Notes database
by Zero_Flop (Pilgrim) on Feb 12, 2005 at 07:25 UTC
    The original program cycles over all the views ( or folders, Notes treats both views and folders the same ). If you go back to the program you will see "$viewname =~ s(\\)(.)g;" In LN the views (folders) are seperated by "\" So, folder->subFolder will be returned from LN as folder\subFolder in $viewname. Then it's converted to folder.subFolder.

    It may be as simple as replacing "\" to "/" so when you "my $path = "$dir/$viewname"; " you will end up with my $path = "$dir/folder/subFolder ";

    Zero
      Thank you for the ideas, I have to try that on monday, then I can tell you if it works.
      Enjoy your weekend!

      Tobi