OK, this is just driving me crazy.

I'm calling Word Automation using Win32::OLE, and to open a file I use e.g.:

use Win32::OLE qw(CP_UTF8); $Win32::OLE::CP = CP_UTF8; my $W = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application') || die ("couldn't create Word object"); my $document = $W->Documents->Open("my.doc");

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.


In reply to Win32::OLE and taint by Michael Roberts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.