instantiate a hash open file of unique keys while read a line get the key from it make it a key in your hash, with its value being a reference to an array containing four zeros for N = 1 to 4 open file1 while read a line split the key and value out of it if the key exists in your hash assign the value to your hash as the Nth element of an array referred to by this key if the key doesn't exist skip it or error, depending on your design for each key in the hash if any of its array's elements are non-zero print the key and array elements joined by tabs