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])..
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;
OUTPUT:
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


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.