--14dae9340773359c0e04b1a5c345 Content-Type: text/plain; charset=ISO-8859-1 That's a good point & idea. I will take that into consideration and will most likely use the loop like you suggested. Thanks. On Sun, Nov 13, 2011 at 12:27 PM, Dave Aronson < rubytalk2dave / davearonson.com> wrote: > On Sat, Nov 12, 2011 at 21:42, Reese Chappuis <c0dege3k / gmail.com> wrote: > > > Ok, that does work- so the problem is with how the data is being > inputted, > > not with the program? > > No, it's the program, if you do indeed want to use gets. Thing is, > you're just using gets *once*, and gets just reads one line. I don't > see how you could have wound up with multi-line results from one gets > call in irb. Possibly the modifications you glossed over, were doing > a good bit more than that. Anyway, there are a couple alternate > suggestions that spring to mind. > > One is to use a different input reading function that will read until > end-of-file, and then split it as you were doing. The user must press > ^Z when done (^D on Mac or Linux). However, typical non-technical > end-users might not understand things like "press ^Z". (I'm guessing > this is really just an academic exercise so that wouldn't really > matter, but it's still a good idea to get into the habit of thinking > about what your users will understand or not.) Also, reading until > EOF in one chunk can be a dangerous habit to get into, as some joker > (or malicious attacker) may enter much more data than your program can > really handle. (Again, good habit to get into thinking about security > and scalability.) > > A much better way is to put gets in a loop with some condition to end > it, such as entering a blank line. How to initialize the data and > execute that loop, are left as exercises for the reader. > > -Dave > > -- > LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern > languages. > Where: Northern Virginia, Washington DC (near Orange Line), and remote > work. > See: davearonson.com (main) * codosaur.us (code) * dare2xl.com(excellence). > Specialization is for insects. (Heinlein) - Have Pun, Will Babble! > (Aronson) > > -- Reese Chappuis --14dae9340773359c0e04b1a5c345--