I note from your previous node
Comparing 2 csv files that other monks have pointed
Text::CSV out to you, so hopefully you are using it to parse and generate the files. Assuming you have a fixed number of source ("other") files, you could create a hash for each one (keyed on your index, i.e. 10, 4, 8...) and then output the key followed by the three hash values. If the number of source files is arbitrary, you'll likely want an array of hashes -
perllol has details on working with those.