Shows what I get for replying without running the code (and
just jumping to a conclusion). While you might see a difference
in the way AP and Cygwin Perl handle newlines (again, depending
on how your Cygwin filesystem is configured), I have to belatedly
second Jenda's and David Wagner's id of the problem.

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

Under Win32, you can't use single quotes (') to pass arguments on the
command line. Rather, you have to use double quotes (").

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

I should have clued in that the MD5 sums were unchanged above.
That's a clear indication that your script made no changes.
In this case, because of the way you invoked it.

Mind you, using single quotes on the command line under Cygwin
and other Unixes is preferrable when you are doing things like:

  > perl -e '$s = "my dog"; print "$s has fleas\n"'

so that the special chars to the shell (e.g. $ ) do no have to
be escaped.

--
Mike Arms


-----Original Message-----
From: Arms, Mike [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 4:16 PM
To: 'Steve Harper'; [EMAIL PROTECTED]
Subject: RE: Search and replace one-liners in ActivePerl broken?


Heh, liked the "Outlook is silly" flag.

Anyway, the difference has to do with newlines. Under Win32,
ActivePerl prints "\n" as "\r\n". Cygwin (depending on how
you have its filesystems configured) prints "\n" as "\n". Check 
the size of your output files. For a two line file, I would 
expect there is a 2 byte difference in size.

You could also do this under Cygwin:

  diff -b outfileAP outfileCyg

The -b option ignores differences in whitespace.

Or you could run a dos2unix program on your outfileAP
file to end up with exactly the same file as outfileCyg.

--
Mike Arms


-----Original Message-----
From: Steve Harper [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 4: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

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

Reply via email to