in reply to Re^2: To Read and Edit docx files in Windows 7
in thread To Read and Edit docx files in Windows 7

Firstly, I highly recommend using use strict; and use warnings; or use version; (replacing version with your Perl version number). Especially when using Win32::OLE.

Next, I highly suspect $word->Quit(); is not necessary, as Word should already close when you close the last document you have open. This is (I think) the most likely source of the error you are experiencing.

Replies are listed 'Best First'.
Re^4: To Read and Edit docx files in Windows 7
by DVCHAL (Novice) on Dec 16, 2014 at 05:11 UTC
    When I use use strict or use Version I get the following Error

    Global symbol "@filesnames" requires explicit package name at Author_doc_read_ne w.pl line 31. BEGIN not safe after errors--compilation aborted at Author_doc_read_new.pl line 31.

    This Error is against the line @filesnames = glob '*.docx' , How to get rid of this error?
      Hmm, so strict is complaining, what do, what do ... satisfy strict somehow ... what does strict say about that ... strict vars says
      This generates a compile-time error if you access a variable that was neither explicitly declared (using any of my, our, state, or use vars) nor fully qualified. (Because this is to avoid variable suicide problems and subtle dynamic scoping issues, a merely local variable isn't good enough.) See "my" in perlfunc, "our" in perlfunc, "state" in perlfunc, "local" in perlfunc, and vars.

      So I think my @files = ...;

      Maybe :/

        my @files = resolves the error. Thanks for the Hint.

        Now I am with another Problem, when I open the word document named myfile.docx, another instance of "myfile" is getting opened in the name "~myfile.docx", Since i am parsing through all docx files(*.docx) in the working folder, The Win::OLE try to open this duplicate instance(~myfile.docx) also. But I am closing my opened Docs using $document->Close(), But that doesn't solve the issue. Any suggestion what goes wrong here?