develooper Front page | perl.golf | Postings from June 2008

=?gb2312?B?tPC4tDogQSBjaGFsbGVuZ2UgdG8gZXhwbGFpbiB0aGUgc3RyYW5nZQ==?==?gb2312?B?IHJlc3VsdHMgKHVuZGVyIGxpbnV4KQ==?=

Thread Previous | Thread Next
From:
Zhu Shanshan
Date:
June 11, 2008 22:30
Subject:
=?gb2312?B?tPC4tDogQSBjaGFsbGVuZ2UgdG8gZXhwbGFpbiB0aGUgc3RyYW5nZQ==?==?gb2312?B?IHJlc3VsdHMgKHVuZGVyIGxpbnV4KQ==?=
Message ID:
000901c8cc4d$64cd3fa0$2e67bee0$@ac.cn
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:rjk-perl-golf@tamias.net] 
发送时间: 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



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About