From: Robert Klemme Date: 2010-04-05T04:10:05+09:00 Subject: Re: Reading contents of all files from a Directory On 04.04.2010 19:58, Hawksury Gear wrote: >> Even better >> >> require 'pathname' >> dir = Pathname "K:/test" >> >> dir.each_entry do |file| >> if file.file? >> file.each_line do |line| >> ... >> end >> end >> end >> >> Cheers >> robert > > Many Thanks Robert, I did the following, > > require 'pathname' > dir= Pathname "K:/test" > dir.each_entry do |file| > if file.file? > file.each {|line| print line} ## Checking if it can access a line in a > file > end > end > > It isn't giving any error message which is great but also not Displaying > any Output. Are you sure? irb(main):004:0> pn.each {|l| p l} NoMethodError: undefined method `each' for # from (irb):4 from /usr/local/bin/irb19:12:in `
' > Probably i am not using file.each{|line| print line} correctly. I suggest you read my posting again and / or consult documentation. Regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/