From: "Peña, Botp" Date: 2008-04-04T13:15:04+09:00 Subject: Re: using a range as a key From: Michael Linfield [mailto:globyy3000@hotmail.com] # ...12345..12350 => 89734, 23456..23460 => 23532 # ect ect. commas separating the ranges like above...How do I # import the literal of that file instead of the string. # file = File.readlines('testdata.txt') # this creates only 1 array # element # file[0].class # #=> String # file[1] # #=> nil # So this obviously wouldn't work in a manner of the following: # ranges = RangedHash.new(file) # Same goes for file = File.open('testdata.txt', 'w+') if it's text you can eval it (note that there are other ways). eg, file="12345..12350 => 89734, 23456..23460 => 23532\n" #=> "12345..12350 => 89734, 23456..23460 => 23532\n" file.strip! #=> "12345..12350 => 89734, 23456..23460 => 23532" file #=> "12345..12350 => 89734, 23456..23460 => 23532" h=eval("{"+file+"}") #=> {23456..23460=>23532, 12345..12350=>89734} h.class #=> Hash kind regards -botp