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

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?

Replies are listed 'Best First'.
Re^5: To Read and Edit docx files in Windows 7
by Anonymous Monk on Dec 16, 2014 at 07:26 UTC
    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?

        This is a temporary file created (and usually later deleted) by Word.

        Generally, you should exclude temporary files from processing. For Word, that's names beginning with ~ (except if your users really name their files like that :-/ ), and also files with zero size, which some versions of word seem to use as a lock indicator.