in reply to Grouping an array of hashrefs by similar key values

First, your structure makes no sense. I think you mean
@items = ( { item_key => '1', item_description => 'description 1', item_summary => 'item summary 1', actions => [ { key => '1', summary => 'summary 1' }, { key => '2', summary => 'summary 2' } ] }, ... );

You could technically use the last two techniques to build the data structure you desire from the data structure you presented, if you can't build the data structure you desire directly from the database (as shown).

Replies are listed 'Best First'.
Re^2: Grouping an array of hashrefs by similar key values
by perldj (Initiate) on Jan 29, 2009 at 19:24 UTC
    Thanks for the reply ikegami - very useful.

    I ended up using your third method in the end. May I ask what the 'local *item' actually means though? Other than that bit of code I understand what it does.
      It aliases $item to $items{ $row->{item_key} }. Changes to one affect both. I could have done $item_ref = \( $items{ $row->{item_key} } );, but it made the subsequent code rather messy (but not as much as using neither).