Hi, At Thu, 12 Jun 2003 17:52:02 +0900, Andrew Walrond wrote: > Futher investigation proved to be confusing. Can anyone explain whats > going on? > (I've appended the output from each line to make it easier) It looks position mismatch between stdio and IO descriptor. Although this would be a bug, try with #seek before #dup. > #!/bin/ruby -w > #Hello cat > #Hello dog > #hello canary > > puts DATA.gets #-> one Ok, as expected. > puts DATA.gets #-> two Ok, as expected. > DATA.seek(0, IO::SEEK_CUR) > a=DATA.dup > puts a.gets #-> nil Huh? I was expecting 'three' > a.rewind # Try rewinding... > puts a.gets #-> #!/bin/ruby -w Ok, I can live with that > DATA.seek(0, IO::SEEK_CUR) > b=DATA.dup > puts b.gets #-> nil Hmmm. Ok, same as before > b.rewind # Rewind... > puts b.gets #-> #!/bin/ruby -w As expected But it doesn't work with the below, so more investigation is needed. > # Ok, lets simplify it a bit > > c=DATA.dup > c.rewind > d=DATA.dup > d.rewind > puts c.gets #-> #!/bin/ruby -w As expected > puts d.gets #-> nil What the hell is going on here? -- Nobu Nakada