Newbie - Q: working with files

Hi,

I have a function with the following code

def first_parse
@in_file.each_line do |line|
puts line
@line += 1;
tokens = line.split
handle_command(tokens, line)
end
puts “End of file reached”
@heap.dump(@obj_file)
end

The problem is that I parse the entire file (@in_file), and my app
exits, but I never execute the puts “End of file reached”. Anyone have
any ideas why?

On Jul 20, 2006, at 4:37 AM, Allison N. wrote:

end
puts “End of file reached”
@heap.dump(@obj_file)
end

The problem is that I parse the entire file (@in_file), and my app
exits, but I never execute the puts “End of file reached”. Anyone
have
any ideas why?

I would wonder if something’s happening in handle_command. Or maybe
there’s an output buffering problem going on. You could try
‘$stdout.sync = true’. But this is all just blind guessing.
-Mat

handle_command(tokens, line)

end
puts “End of file reached”
@heap.dump(@obj_file)
end

The problem is that I parse the entire file (@in_file), and my app
exits, but I never execute the puts “End of file reached”. Anyone have
any ideas why?

Maybe something is going wrong in your handle_command call that makes
the program exit without finishing. Make sure you are running ruby with
warnings on and that might help a little.

Tait P.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs