Reading contents of all files from a Directory

On 04.04.2010 19:58, Hawksury G. wrote:

end
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 #<Pathname:clnt.rb> 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

On Sun, Apr 4, 2010 at 7:58 PM, Hawksury G.
[email protected] wrote:

end
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.
Probably i am not using file.each{|line| print line} correctly.

Try:

file.foreachline {|line| print line}

It seems Pathname objects don’t have an each method…

Jesus.

Probably i am not using file.each{|line| print line} correctly.

I suggest you read my posting again and / or consult documentation.

Regards

robert

All works , Thanks very much!