in reply to Win32::OLE Word Search and Replace Script Runs Locally but not as part of CGI

I belatedly realised why your program is not working:

my $oldfile = 'c:\tmp\test.doc'; my $newfile = 'c:\tmp\test1.doc';
Do your filenames REALLY have tab-stops in them?

Using proper slashes will almost certainly solve your problem.

my $oldfile = 'c/tmp/test.doc'; my $newfile = 'c:/tmp/test1.doc';

--
Regards,
Helgi Briem
helgi AT decode DOT is

Replies are listed 'Best First'.
Re (2): Win32::OLE Word Search and Replace Script Runs Locally but not as part of CGI
by VSarkiss (Monsignor) on Feb 14, 2003 at 15:42 UTC

    No, that's not right. In single quotes, the backslash escapes do not apply (backslash only escapes the ' character). Had he been using double quotes, tabs would have been interpolated for the \t sequence.

    Try it:

    > perl -de 1 Default die handler restored. Loading DB routines from perl5db.pl version 1.07 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> $x = 'c:\tab' DB<2> p $x c:\tab DB<3> $x = "c:\tab" DB<4> p $x c: ab DB<5> q

    The most likely cause of the problem, as others have pointed out above, is that the script doesn't have permission to read the file it's trying to open, but the error is not being trapped.

Re 2: Win32::OLE Word Search and Replace Script Runs Locally but not as part of CGI
by bart (Canon) on Feb 15, 2003 at 23:58 UTC
    I agree with you that the way these paths are defined, is unclean. In general, for use in perl alone, I'd agree with your conclusion: to use forward slashes. However, this is not just perl: the paths are passed as parameters via OLE to Word. I cannot test my hyphotesis, but I seriously doubt whether Word would accept paths with forward slashes. From what I remember with my experience with OLE and Excel, a program from the same stable as Word, is that it was extremely unhappy about forward slashes in file paths: it only accepted backslashes as a valid directory separator.

    Conclusion: using backslashes in the paths is more than justified here. However, the way they're used in writing down these strings, is still unclean.