Try this. It won't produce exactly the output you are after, but it should show you how to access the various datasets so that you can manipulate them to your requirements.

# Get an arbitrary top level key and use it to # create an ordered array of the sub hash keys my $anyKey = keys %{ $hashref1 }; my @sortedKeys = sort keys %{ $hashref1->{ $anyKey } }; for my $id ( sort keys %{ $hashref1 } ) { # extract an array of *ordered* results for this key from each has +h my @results1 = @{ $hashref1->{ $id } }{ @sortedKeys }; my @results2 = @{ $hashref2->{ $id } }{ @sortedKeys }; my @results3 = @{ $hashref3->{ $id } }{ @sortedKeys }; ## join them together with spaces ## and print them along with the key printf "%14s : \t%s\n\t\t%s\n\t\t%s\n\t\t%s\n", $id, join( ' ', @sortedKeys ), join( ' ', @results1 ), join( ' ', @results2 ), join( ' ', @results3 ); }

If, for example, you want to have the columns in some order other than alpha-sorted, just hard code the keys array. Ie. Replace the sort (first two lines of code) with:

# Get an arbitrary top level key and use it to # create an ordered array of the sub hash keys # my $anyKey = keys %{ $hashref1 }; # my @sortedKeys = sort keys %{ $hashref1->{ $anyKey } }; # Create an array of keys in the order you want them { ## Suppress 'Possible attempt to put comments in qw() list at ...' ## because of the key: '#' no warnings 'qw'; my @sortedKeys = qw[ Cardiology Neurology All_sum call_date Gastroenterology General # Radiology ]; }

Just put the column names in whichever order you wish them to appear. Also, omit any that you don't want.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^5: Merging Results from 3 different queries by BrowserUk
in thread Merging Results from 3 different queries by MegaVoice

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.