From: Valentino Lun Date: 2009-02-16T19:00:19+09:00 Subject: How to do this complicated logic in ruby Dear all I have an array with size around 1000, I want to perform some data checking and correction in this array. For instance, the first record of this array is a hash, as follow my_array[0] = {"server"=>"AHN", "hosp"=>"AHN", "loc"=>"PC1", "pspec"=>"ANA", "number"=>"1", "pcat"=>"1"} server hosp loc pspec pcat AHN AHN PC1 ANA 1 PWH AHN PC1 ANA 1 NDH AHN PC1 ANA 2 <= This pcat value need update in array1 TMH AHN PC1 ANA 2 <= This pcat value need update in array1 ....... ..... ... (around 1000 records) When keys hosp, loc, pspec has the same values, their pcat must be identical. So, there is problem in the last two records, the key pcat should be 1, because the pcat is correct if array["server"] equal to array["hosp"]. I cannot figure out the logic to doing this in ruby (even in other language). Can someone give me some hints on this? Thanks Many thanks Valentino -- Posted via http://www.ruby-forum.com/.