David wrote:
[EMAIL PROTECTED]:~/ruby $ irb
irb(main):012:0> puts $stdin.readlines.sort_by {rand}
1
2
3 <-- c^d here
3
2
1
=> nil
irb(main):013:0> puts $stdin.readlines.sort_by {rand} unless $stdin.eof
=> nil
irb(main):014:0>
In other words, it looks like you don't want the <unless $stdin.eof>,
because it seems to get eof before you get a chance to enter anything.
The reason for not being able to enter is because after you put
"irb" you must have put c^d before you put the command,
puts $stdin.readlines.sort_by {rand} unless $stdin.eof.
This is so, because the stored value is now EOF(nil) in $_.
So, after you put C^d your command line should really be,
"puts $stdin.readlines.sort_by {rand} unless not $stdin.eof"
and NOT
"puts $stdin.readlines.sort_by {rand} unless $stdin.eof".
This will enable you to put many lines because your $_ has
a value of EOF(nil) and we are saying "not $stdin.eof".
$_ contains the last entered line when
you do "gets" or "readline".
Hope this helps.
O Plameras
------------------------------------------------------------------------
* *References*
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders