http://www.perlmonks.org?node_id=997052


in reply to Format a Dumper module output file.

The output of Data::Dumper can be turned back into a Perl variable using eval (or do if it's in a file), so
#!/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} }); }
Then
% perl fmt.pl output.dump AIG 154 160 161 135 GID 18 27 18 17 TEA 235 224 224 214
where output.dump is just
$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, } };

Replies are listed 'Best First'.
Re^2: Format a Dumper module output file.
by oxydeepu (Novice) on Oct 03, 2012 at 13:30 UTC

    Thank you all.
    The response was amazing.
    Thanks Arun,this what i needed.

    Best,
    Deepak