drodinthe559 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, can anyone tell me why the below code won't work. I'm able to make a backup of the file but the original file goes unchanged. I'm doing this on Windows XP. Could that be why its not working? perl -i.txt -pe 's/\s//g' test.log

Replies are listed 'Best First'.
Re: command line search and replace
by toolic (Bishop) on Dec 06, 2011 at 21:43 UTC
    I can reproduce your results in a DOS shell. When I change to double-quotes, it behaves as you desire (it removes all whitespace from the test.log file):
    perl -i.txt -pe "s/\s//g" test.log
Re: command line search and replace
by AnomalousMonk (Archbishop) on Dec 06, 2011 at 21:58 UTC

    BTW: Use of warnings produces the same unwanted result described in the OP plus a helpful warning (xxx is a text file with whitespace):

    >perl -wMstrict -i.bak -pe 's/\s//g' xxx Useless use of a constant (s/\s//g) in void context at -e line 1.
      That makes sense. Thanks for your help.