Hi!

* Joel VanderWerf:
> Philip Mak wrote:
> >What's the shortest way to regurgitate the contents of a file? I mean
> >like this:
> 
> puts File.read("filename.txt")

AFAIK that reads the whole file to memory while

    File.open("filename.txt") {|f| f.each {|l| puts l}}

reads one line at a time. One should add that this only works because
puts does not add a line break to strings that already end in one. It
would be better to send the String object a chomp message:

    File.open("filename.txt") {|f| f.each {|l| puts l.chomp}}

Nevertheless that only plays a role when doing something more
complicated with l.

Josef 'Jupp' SCHUGT
-- 
http://oss.erdfunkstelle.de/ruby/    -     German comp.lang.ruby-FAQ
http://rubyforge.org/users/jupp/     -     Ruby projects at Rubyforge
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Germany 2004: To boldly spy where no GESTAPO / STASI has spied before