#!/usr/bin/perl
use strict;
use warnings;
my $file = shift or die 'no file given';
# parse output file
my $var = do $file;
my %words;
foreach my $col (sort keys %$var) {
my $hash = $var->{$col};
# collect values for each word
while (my ($k, $v) = each %$hash) {
push @{ $words{$k} }, $v;
}
}
foreach my $word (sort keys %words) {
printf "%s %s\n", $word, join(' ', @{ $words{$word} });
}
####
% perl fmt.pl output.dump
AIG 154 160 161 135
GID 18 27 18 17
TEA 235 224 224 214
##
##
$VAR1 = {
'3' => {
'GID' => 18,
'AIG' => 161,
'TEA' => 224,
},
'2' => {
'GID' => 27,
'AIG' => 160,
'TEA' => 224,
},
'4' => {
'GID' => 17,
'AIG' => 135,
'TEA' => 214,
},
'1' => {
'GID' => 18,
'AIG' => 154,
'TEA' => 235,
}
};