Forum: Ruby Re: (libruby) reading a file line by line

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Zach B. (Guest)
on 2006-05-25 21:43
(Received via mailing list)
Prehaps something like this

f = File.open("inventory")
f.each do |hostName|
  hostName.chomp!
end
Phil J. (Guest)
on 2006-05-25 23:41
(Received via mailing list)
Hi,

On Fri, May 26, 2006 at 02:41:13 +0900, Zach B. wrote:

[ top post fixed ]

>> Basically what I would like to do is read a file in line by line chomping
>> the line on the way. It's easy enough in c but I would like to do it
>> using the functionality from libruby.

>> I've go the file object using rb_file_open(), can someone suggest how I
>> might use each_line to do what I want to?
>
> Prehaps something like this
>
> f = File.open("inventory")
> f.each do |hostName|
>   hostName.chomp!
> end

Thanks for the answer but I may have been un-clear. I'm wanting to do
this
from a c program using libruby.

Cheers,
Phil
This topic is locked and can not be replied to.