Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: Cee Joe Newsgroups: comp.lang.ruby Subject: Re: File position and buffers Date: Fri, 29 Apr 2011 13:32:00 -0500 Organization: Service de news de lacave.net Lines: 41 Message-ID: References: <10d8ae57765e21626a7c64873dcba807@ruby-forum.com> <12ea664fa8ebe548db95a756061e6489@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1304101965 16790 65.111.164.187 (29 Apr 2011 18:32:45 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 29 Apr 2011 18:32:45 +0000 (UTC) In-Reply-To: <12ea664fa8ebe548db95a756061e6489@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382392 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3707 7stud -- wrote in post #995821: > I suggest that people never use irb because it has too many quirks. > > The first thing you need to realize is that '>' is > not the separator you want to look for. That is the second bit of > erroneous advice your mentor gave you. That's because you don't care > what character marks the beginning of every entry, rather you care what > character marks the end of every entry. The end of every entry in your > file is marked by the string "\n\n", so you should use that as your > input line terminator. Remember, ruby uses "\n" for the input line > separator by default, which means that when you read a file using > IO#each, ruby reads lines--where the end of a line is marked by a > newline. I understand the logic, it makes sense. What if the file looked like this, where there is one newline seperating the entries? : >gi|329295464|ref|NM_2005745.3Acc1| Def1 zgc:65895 (zgc:65895), mRNA AGCTCGGGGGCTCTAGCGATTTAAGGAGCGATGCGATCGAGCTGACCGTCGCG >gi|456299107|ref|NM_2342343.3Acc2| Def2 zgc:65895 (zgc:65895), mRNA GTCGCTGGGTCGAAAAGTGGTGCTATATCGCGGCTCGCGTCGATGTCGCGATG CGTGCGCGCGAGAGCGCGCTATGATGAAAGGATGAGAGAG >gi|3542945647|ref|NM_7453343.5Acc3| Def3 zgc:65895 (zgc:65895), mRNA CGTGCGGGGABCCGTACGTGCCGTGGGGGTTTAATAGCGCGCCATCTGAGCAG TTAGTCGCTGACGCATGCACG Would an if-else(regarding"\n" and "\n\n") do the trick? I wanted to write my code to where it would handle both scenarios. Or maybe: case when "\n\n" when "\n" end something to that extent? Suggestions? -- Posted via http://www.ruby-forum.com/.