develooper Front page | | Postings from June 2008


Thread Previous | Thread Next
Zhu Shanshan
June 11, 2008 22:30
Message ID:
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,

Anyway, thank you again!

发件人: Ronald J Kimball [] 
发送时间: 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 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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About