In that case, what you probably want is a hash of arrays, rather than an array of hashes. You want a hash keyed on the unique IDs in your first file, and values consisting of 4-element arrays. Then you can loop through your hash a second time and print out all key/value pairs that have something other than zero in one of their value elements.
Give that a shot, and if you have trouble, post the code so we can help with it. Pseudo-code would look something like this:
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 a +rray 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
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
In reply to Re^2: How to make a array of hashes and search them
by aaron_baugher
in thread How to make a array of hashes and search them
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |