Text::Table seems handy.
Having two hashes with the same keys, while one of these two hashes (%$keep_best) has at most three elements for each array associated with each one of its keys the other one has a 3-array element associated with each key. So looping through the hash %$best keys and associated array elements is sufficient to blanket elements in the hash %$keep_best as well..values in %$best are completed in %$keep_best (i.e $best{key1}= [1,2,3], $keep_best{key1}=[4,5])..OUTPUT:use strict; use Text::Table; my $best = {'key1'=>[1,2,3],'key2'=>['f','g','h'],'el1'=>['y','z','z1' +]}; my $keep_best = {'key1'=>[4,5], 'el1'=>['w','x'],'key2'=>['i','j','k'] +}; my $table = Text::Table->new("key\n---","BEST\n----","KEEP BEST\n----- +--"); foreach my $key (sort keys %$best){ $table->add($key,@{$best->{$key}}[$_],@{$keep_best->{$key}}[$_]) for (0..$#{$be +st->{$key}}); } print $table;
key BEST KEEP BEST --- ---- --------- el1 y w el1 z x el1 z1 key1 1 4 key1 2 5 key1 3 key2 f i key2 g j key2 h k
In reply to Re: Print multiple hashes of arrays at same time
by biohisham
in thread Print multiple hashes of arrays at same time
by tomdbs98
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |