From: Gani Ruthellen Date: 2007-08-08T04:10:58+09:00 Subject: Re: array.each puzzle from new ruby-er Noah Easterly wrote: > On Aug 7, 2:04 pm, Gani Ruthellen wrote: >> > end >> Posted viahttp://www.ruby-forum.com/. > Have you considered switching to map? > > As for debugging, I'd try tracking it down using p > > lines = file.readlines("\x15").map do |line| > line.chomp!("\x15") > line.sub!(/^\n/, "") > line = "" + line + "" if line =~ /^\*{3}/ > p [:line, line] # comment me out after debugging > line > end > > p [:lines, lines] # comment me out after debugging > > puts lines Oh. I did a subset of the p [:line, line] and it looks like i had some \n and some \r\n occurring. I was just pulling the \r\n on my sub call (wrote it as \n to simplify)because when I was looking at the original with end of line showing they all showed as CRLF. Odd. Much improved output, and another tool in my meager toolkit. Thanks so much, Noah and all other repliers! I'll look at replacing the each with map/collect now that I know about it. I do have the Pragmatic programming book... Cheers, Gani -- Posted via http://www.ruby-forum.com/.