From: Dave Hatton Date: 2007-01-31T02:28:05+09:00 Subject: Correct way to process a file in Ruby? Hi What is the correct way to code the following in Ruby? open file read field from file determine from field the type of file case file type in type 1) do this (lots of stuff) type 2) do that (even more stuff) type 3) do something else (you get the picture) *) error esac close file I presently have this coded as one big method but the number of cases are large and the complexity of the processing increasing. This is going to end up a hell of a larger method. I then thought about breaking it into a number of methods but that resulted in opening and closing the file a number of times (in each method) which feels bad Would it be right to use a global variable as a file descriptor and open the file in one method which returns a fd and then having a number of methods processing using the fd and then finally having a method that closes the file? Sorry if I'm seem to be grasping for the correct Ruby language to express this - I'm very new to Ruby coming from a C and shell background. Daveh -- Posted via http://www.ruby-forum.com/.