From: Jeff 'japhy' Pinyan Date: 2002-02-04T12:17:22+09:00 Subject: Re: range and modification On Feb 4, Sung Moon said: >n[4..8].sort! doesn't work(same for compact!, collect!) That's because a = b[4..8] doesn't make a[0] through a[5] "aliases" to b[4] through b[8]. b = (0..19).to_a a = b[4 .. 8] a[0] = 99 puts b.join(" ") You'll see that b[4] is still 4, not 99. >Is there any elegant way to do this job? n[4..8] = n[4..8].sort is my best suggestion. >2. It seems LAST line in text does not have \n or \r\n, > (I used Wordpad for creating this text) > so I can't use chop/chomp without losing last digit/character. Uh, you can use chomp() safely. ["jeff\n", "japhy"].each{|str| puts "<#{ str.chomp }>"} # and -- 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.