in reply to Table data

foreach ... @consolidated_data = ... }

This would overwrite previous results every time the foreach loop executes. You need

foreach ... push @consolidated_data, ... }

Hint: Use Data::Dumper to print out the variables in your script. Then you find out exactly where the scripts starts to misbehave and often why. You also will find out if your regexes match what you want them to match