I think the thing that's missing is the -w after perl:
  C:\TEMP>perl -w -pi.bak -e 's/this/that/g' testtextfile.txt
  Useless use of a constant in void context at -e line 1.

Cryptic, but clearly something is not right.

Actually, Jenda had the answer to the actual problem (shell interpretation
rules), but I just wanted to point out that our friend the -w switch helps
even with one-liners.

hth,

Craig Arnold
Boeing Space & Communication
International Space Station
Guidance, Navigation & Control
Huntington Beach, CA 

-----Original Message-----
From: Steve Harper [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 3:04 PM
To: [EMAIL PROTECTED]
Subject: Search and replace one-liners in ActivePerl broken?


Can someone please tell me why the following doesn't work?  Observe:

In Windows 2000 CMD.exe, with ActiveState Perl 5.6.1 Build 631
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\>copy con testtextfile.txt
This is this, that is that
Thats all folks!
^Z
        1 file(s) copied.

D:\>perl -pi.bak -e 's/this/that/g' testtextfile.txt

D:\>md5sum test*
ca08d1da587bff5a25bb33f22fa62df7 *testtextfile.txt
ca08d1da587bff5a25bb33f22fa62df7 *testtextfile.txt.bak

D:\>rm *.bak
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, lets try that in Cygwin w/ it's perl v5.6.1...

Administrator@PSIONIC /cygdrive/d
$ perl -pi.bak -e 's/this/that/g' testtextfile.txt

Administrator@PSIONIC /cygdrive/d
$ md5sum test*
74d5c5e10b51b882fa5438a4f99cc111 *testtextfile.txt
ca08d1da587bff5a25bb33f22fa62df7 *testtextfile.txt.bak

Administrator@PSIONIC /cygdrive/d
$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm fairly perplexed by this difference in behaviour, I've read a fair
amount in the documentation to try to figure this out, but nothing I've
seen has really answered my question.  I'm sure its something stupid, like
shell differences, but it seems like the perl runtime is getting
everything it needs here and is still not making the changes to the file.

Thanks in advance for any help on this.

Steve Harper
Software Developer
Campus Student Computing
University Of Utah

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to