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

I am running up against a culture clash between a VB programmer who wrote some OLE accessible code and my understanding of Perl usage. I've gotten a lot of complex stuff to work, but hit a brick wall on this one. I hope someone here can educate me. This is using Win32::OLE
VB usage:
$OLE1.Net.PasswordTimeout = 45
This works in VB.

my Perl translation:
$OLE->Net->PasswordTimeout = 45;
returns "can't modify non-lvalue ..." as I expected.

I thought it should be:
$OLE1->Net->PasswordTimeout(45);
This returns a "does not support a collection" error.

I think the VB programmer has done something very wrong, and the second perl syntax is correct. He is trying to use the same syntax to both get and set the value.
i.e. $h = $OLE->Net->PasswordTimeout;
works correctly and returns the proper value. But I do not understand how he would be setting the value using the equate the same way. Yet the VB code works fine, while the perl gives errors. I think he should use a new method SetPasswordTimeout to set it. Most other objects have distinct read and write methods, but not this one. Of course, since his VB code works to access the function, he thinks perl is at fault. I'm thinking perl is catching an error that VB is permitting. Just because VB allows it does not mean it is correct, right? Or is there a different perl syntax for this sort of thing that I am ignorant of? I've spent a lot of time reading about objects in perl, but I remain ignorant.

Clearly I am beyond my experience. Can someone explain to me where I am failing?
Thanks,
Nat

Replies are listed 'Best First'.
Re: Perl and OLE Help needed
by Corion (Patriarch) on Feb 07, 2008 at 06:55 UTC

    Have you tried:

    $OLE1->Net->{PasswordTimeout} = 45;

    In general, VB is quite strict about how its objects/variables can be accessed. Look at the Win32::OLE documentation to read about the different ways available to access OLE objects from Perl.

      Thanks for the suggestion.
      $OLE1->Net->(PasswordTimeout) = 45;
      returns "not a subroutine reference"

      I will re-read the WIN32::OLE docs again. But so far, no help.
      Thanks,
      Nat

      OH! Wait!
      $OLE1->Net->{PasswordTimeout} = 45;
      (Braces, not Parens!) It WORKS IT WORKS!!

      Much thanks,
      Nat

        Read my node again. I used curly brackets {...}, not round parentheses.