答复: A challenge to explain the strange results (under linux)

[email protected] ("Zhu Shanshan") Thu, 12 Jun 2008 13:29:59 +0800
Newsgroups perl.golf
Message-ID <[email protected]>
Thanks.
As you said, when I substituted "s/\r\n$//" with "chomp", it did work. =
After
looking up the explanation of "chomp" in perldoc, I found "chomp", which =
I
always used to remove the newline previous, removes any trailing string =
that
corresponds to the current value of "$/". And this time, it removed "\n" =
for
me. I'm really puzzled by this phenomena, because I always work with
"chomp". I guessed the problem came from the new SFTP software used
recently. Then I compared it with WinSCP using the same script. Bingo!
WinSCP has deleted "\r" for me and that's why I could luckily work,
previous.

Anyway, thank you again!


-----=D3=CA=BC=FE=D4=AD=BC=FE-----
=B7=A2=BC=FE=C8=CB: Ronald J Kimball [mailto:[email protected]]=20
=B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C212=C8=D5 12:28
=CA=D5=BC=FE=C8=CB: Zhu Shanshan
=B3=AD=CB=CD: Perl Golf
=D6=F7=CC=E2: Re: A challenge to explain the strange results (under =
linux)

I would bet that your color.txt file has Windows line endings on all
platforms.  If you do this:

  perl test.pl color.txt | less

you may find that you're getting output after all.


Make sure color.txt has Unix line endings on the Linux machines.  Here's
one way to fix it:

  perl -pi -e 'tr/\r//d' color.txt

Ronald