I've got some data in a database table like this:
[cams] users> SELECT *, DAY(stats_date) as stats_day FROM stream_updat +e_stats_daily WHERE MONTHNAME(stats_date)='March' AND YEAR(stats_date +)=2006 ORDER BY DAY(stats_date) LIMIT 3\G *************************** 1. row *************************** stats_date: 2006-03-01 diary_entries: 2 photos_uploaded: 0 videos_uploaded: 0 stream_questions: 0 msgs: 12 date_entered: 2006-03-27 17:32:28 messages_received: NULL stats_day: 1 *************************** 2. row *************************** stats_date: 2006-03-02 diary_entries: 7 photos_uploaded: 0 videos_uploaded: 0 stream_questions: 0 msgs: 4 date_entered: 2006-03-27 17:35:43 messages_received: NULL stats_day: 2 *************************** 3. row *************************** stats_date: 2006-03-03 diary_entries: 2 photos_uploaded: 0 videos_uploaded: 0 stream_questions: 0 msgs: 2 date_entered: 2006-03-27 17:42:10 messages_received: NULL stats_day: 3 3 rows in set (0.01 sec) [cams] users>

and I have the ability to turn this data into a Perl array of hashrefs, with one array element for database row:

@ar = ( { stats_date => '2006-03-01', diary_entries => 2, msgs => 12, stats_d +ay => 1}, { stats_date => '2006-03-02', diary_entries => 7, msgs => 4,. stats_d +ay => 2}, { stats_date => '2006-03-03', diary_entries => 3, msgs => 2,. stats_d +ay => 3}, );

But the issue is, I need a hashref of arrays so that this data can be properly displayed:

{ diary_entries => [ 2, 7, 3], msgs => [ 12, 4, 2] }
I thought there was a CPAN module that did this sort of thing but I can't recall the name of it.

In reply to Converting an array of hashrefs into a hashref of arrays by santonegro

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.