From: lionbarrage Date: 2009-02-25T10:20:01+09:00 Subject: Help with Multi Dimensional Array I'm new to ruby and have been trying to figure out what I'm doing wrong. I'm completely stumped about how to merge two files together based on whether they share the same key or not. Example: File 1 ALPHA|OMEGA|GAMMA 1 | 2 | 3 4| 5| 6 File 2 EPSILON|GREEK|OMEGA|BETA 7| 8| 9| 0 12| | 13| 10| 11| 5| 15 End result should be: ALPHA|OMEGA|GAMMA|EPSILON|GREEK|BETA 1 | 2 | 3 | | | 4 | 5 | 6 | 10| 11| 15 | 9| | 7| 8| 0 | 13| | 12| | Currently I have tried this: array_file1 = [] array_file2 = [] row = 0 IO.foreach("file1.txt" ) { |line| array_file1[row] = line.split("|") row += 1 } row = 0 IO.foreach("file2" ) { |line| array_file2[row] = line.split("|") row += 1 } N = array_file1.length array_file1.times(N) { |row| if array_file1[row][1] == array_file2[row][2] array_file2[row].each{ |col| array_file1[row][array_file1i[row].length] = col } end } But I get Undefined Method Logically, I want to loop through row of array_file 1{ check to see if array_file1.OMEGA is equal to array_file2.OMEGA loop through column insert contents of array_file2 to end of array_file1 end loop end loop Any help would be greatly appreciated!