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!


-----邮件原件-----
发件人: Ronald J Kimball [mailto:[EMAIL PROTECTED] 
发送时间: 2008年6月12日 12:28
收件人: Zhu Shanshan
抄送: Perl Golf
主题: 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


Reply via email to