Thanks that worked great! Can you tell or point me to somewhere where it explains the weirdness. Thanks again!

I personally believe that there's no weirdness at all: system either wants a single string as an arguments list, or a several ones. In the former case, the string is parsed for shell metacharachters and if any, it is processed by the system's shell, otherwise, it is split up in "words" and executed directly by the suitable system call. The same happens in the latter case, directly. Now, your code as you posted in the root node is

system(perl -pib -e "s/CAT/mouse/g" 'D:\tmp\file.txt');

which would seem to fall in the second category, but most importantly contains many barewords: these should be disallowed at all if you're running under strict and you know you should run under strict except perhaps with the simplest oneliners. There should be no difference between operating systems wrt this issue. Moreover, the barewords are not separated by commas which also would make for a Perl syntax error irrespective of the OS, and strict too. All in all, you seem to think that whatever is an argument to system() doesn't need any quoting, as if perl itself were a shell, but that's not the case. You either want:

system qq|perl -pib -e "s/CAT/mouse/g" 'D:\tmp\file.txt'|;

(in which I used alternate delimiters on the outer string not to have to quote double quotes inside it) or

system 'perl', '-pib', '-e', '"s/CAT/mouse/g"', q|'D:\tmp\file.txt'|;

Incidentally, since no argument contains spaces, you may rewrite the latter like

system qw|perl -pib -e "s/CAT/mouse/g" 'D:\tmp\file.txt'|;

but pay attention in the general case! Whatever, in both cases you may have an OS quoting problem: you're giving perl a cmd line argument of 'D:\tmp\file.txt' which it will interpret literally as a filename, much different from D:\tmp\file.txt as you can see for yourself:

C:\temp>perl -lpe "" foo.txt foo bar C:\temp>perl -lpe "" 'foo.txt' Can't open 'foo.txt': No such file or directory.
--
If you can't understand the incipit, then please check the IPB Campaign.

In reply to Re^3: System call in Windows by blazar
in thread System call in Windows by csarid

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.