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.
|