in reply to Appending values to existing hash key
As others have said, I approach these problems by looking for a representative data-structure, first; a way to get the data into that structure, second; a way to produce the desired output from that structure, third. Perl’s “auto-vivification” features are already designed to make the construction of such data-structures very easy.
If you try to go too-directly from input to output, soon enough someone will want you to add another output, or to do something else with the data between the input and output stages.