Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How do I obtain a list of values for all the properties of a Word document using Win32::OLE?

by ikegami (Patriarch)
on Jun 11, 2009 at 18:26 UTC ( [id://770725]=note: print w/replies, xml ) Need Help??


in reply to How do I obtain a list of values for all the properties of a Word document using Win32::OLE?

Second, there seems to be a property whose value itself recurses, because I keep getting the same properties over and over after a short period of time

When you brought up your problem in the CB, I postulated that the reason you were running our of memory is that properties formed an infinite loop. You've just confirmed this.

The problem isn't in Data::Dumper. It detects loops in data.

$ perl -MData::Dumper -e'my $x = {}; $x->{x} = \$x; print Dumper $x' $VAR1 = { 'x' => \$VAR1 };

The problem is that Win32::OLE doesn't do such checks. When it receives an object, it create a new Perl object to serve as a bridge. Data::Dumper correctly thinks this is a different object, so it proceeds to dig deeper.

  • Comment on Re: How do I obtain a list of values for all the properties of a Word document using Win32::OLE?
  • Download Code

Replies are listed 'Best First'.
Re^2: How do I obtain a list of values for all the properties of a Word document using Win32::OLE?
by romandas (Pilgrim) on Jun 11, 2009 at 18:38 UTC
    I understand what you're saying, but I would appreciate some clarification on a couple things...
    You mentioned that Win32::OLE doesn't perform the checks, but that Data::Dumper does. However, if I understand my own code (unlikely, but I have hope), I'm not calling Win32::OLE repeatedly.. I thought I just had one Data::Dumper call, and it took care of the rest.. thus, if it functioned as you say, wouldn't it find the 'infinite' loop?

    I suspect I'm not understanding how Data::Dumper works. BTW, above I'm referring to when I just passed $doc straight to Data::Dumper, not when I used the recursive function. Does that make sense?

      Win32::OLE objects aren't copies of the foreign objects. If they were copies, you couldn't affect the remote objects. Each Win32::OLE object is an interface to a remote objects.

      Any fetch from the referenced hash results in a get from the remote object.

      Any change to the referenced hash results in a set in the remote object.

      And yes, you are doing repeated fetches.

      I suspect I'm not understanding how Data::Dumper works.

      It works much like your code, except it doesn't print anything. The output is placed in a string, which is returned when it's done.

        Okay. I can see that now. But.. I'm still at a loss for how to avoid the infinite loop while enumerating all the properties. Any advice?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://770725]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-19 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found