From: Richard Harris Date: 2007-12-13T04:07:35+09:00 Subject: Re: Creating multiple objects in loops Basically it's what I mentioned in my second post (3rd one down). Reading in a text file, parsing it and storing it so I can retrieve it later. I have sorted the reading in and parsing, it's just the best way of storing the information. Text File ------------------------------------------------------------------------------ ID: 1, entry1 # Can have multiple ID's Name: Richard Age: 20 Address: 123 Some Road # Can have multiple lines of address, not fixed Address: Some City Address: Some Country ID: 2 Name: Richard Age: 20 Address: 123 Some Road Address: Some City Address: Some Country ID: 3 Name: Richard Age: 20 Address: 123 Some Road Address: Some City Address: Some Country ------------------------------------------------------------------------------- The text file is in this format but can have multiple id's, and multiple addresses. Also it can have a different amount of fields so one entry might not have an age for example. When it reads in the file it has to then store the entries in a hash for example so all the info below the ID: bit is stored together. e.g. contacts{{"ID"=>{"1","entry1"},"Name"=>"Richard","Address"=>{"123 Some Road","some City","Some Country"}},{"ID"=>{"2"},"Name"=>"Richard","Address"=>{"123 Some Road","some City","Some Country"}}} or something similar, along those lines. So I can say I want the address from the contacts hash where ID equals 1. The thing is I have tried this and can't seem to get it to work at all. any thoughts on how to go about it or another way. Cheers for this R -- Posted via http://www.ruby-forum.com/.