|Perl: the Markov chain saw|
Win32::OLE and taintby Michael Roberts (Sexton)
|on Dec 01, 2013 at 16:01 UTC||Need Help??|
Michael Roberts has asked for the wisdom of the Perl Monks concerning the following question:
OK, this is just driving me crazy.
I'm calling Word Automation using Win32::OLE, and to open a file I use e.g.:
That's it. If I run perl -T, though, I get the "Not a Win32::OLE object" error at the line the object was created when the object goes out of scope and gets freed.
If I don't get the document back as a return value (i.e. I just look for the member of the Documents list that got created when I opened it and ignore the return value from Open), then I get the error at the line where the open is called. If I don't use the return value, but instead allow the variable to go out of scope after doing some other stuff, I get the error with the first line of the scope. And if I assign something else to the variable holding the weird object, I get the error with the line number of the assignment.
So, ignoring for the moment the fact that the line reported reflects the scope of the variable, which is neat but pretty misleading when you're trying to find an error, why the h-e-double-toothpicks does the error not appear when I don't run perl with the taint flag??!??!? I don't even know how OLE.xs knows about the tainting or why it would make a difference to the garbage collector or, really, anything at all. I would like to be able to test and publish a CPAN module with this code without seeing these freaky error messages all over the place with information that doesn't appear to matter to me - because the object in question works just fine and is a perfectly OK Word OLE object.
Help me here.