From: Jeff 'japhy' Pinyan Date: 2002-02-04T13:17:26+09:00 Subject: Re: range and modification On Feb 4, Sung Moon said: >["jeff\r\n", "japhy"].each{|str| puts "<#{ str.chomp.inspect }>"} >==> <"jeff\r"> <"japhy"> It's not OK >["jeff\r\n", "japhy"].each{|str| puts "<#{ str.chop.inspect }>"} >==> <"jeff"> <"japh"> It's not OK > >So, we can use chomp for the line ending with \n, >but we can not use either chop or chomp for line ending with \r\n. Well, you can tell chomp() to use "\r\n". str = "jeff\r\n" puts "<#{ str.chomp("\r\n").inspect }>" In fact, you could do str.chomp.chomp("\r") if you're unsure of whether it's \n or \r\n (or even just \r). -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course.