in reply to Create a hash for each unique captured regex variable

It appears to me that the data you have should be bucketized based on the text before the '_' character. If this is correct, perhaps these pointers will help:

Given the above and your skeleton code, you should be able to piece them together to accomplish your goals.

--MidLifeXis