From: James Rasmussen Date: 2010-08-27T14:22:36+09:00 Subject: File Contents into Hash Table? Hello, I'm trying put some file contents into a hash table. The file contains something like these lines, of the format: "..."=>65, ".."=>66, "["=>67, "]"=>68, "[]="=>69, "<<"=>70, ">>"=>71, "-="=>72, "."=>73, ","=>74, "("=>75, ")"=>76, Where each "_something_"=_some_number_, is on a separate line. I basically need to put all these lines into a hash table. They're already in the hash format as you can see, with commas separating each entry and everything. I can put them from the file into an array, using this: file_contents = [] f = File.open("RubyTokens.txt") or die "Unable to open file..." f.each_line { |line| file_contents.push(line)} But I have no idea how to take each line and put it into a hash table. Is there any way to just read the line in, and put the whole line in as a hash key/value pair? -- Posted via http://www.ruby-forum.com/.