http://www.perlmonks.org?node_id=355457


in reply to Merging an array into an AoH

Are those ids unique? They look like it. If so, I think a hash of hashes would be a better data structure for your problem.
my $box = { q01 => {}, ... q03 => {} }; #this should keep them in the right order my @sorted_keys = sort {lc $a cmp lc $b} keys %{$box} ; for my $id (@sorted_keys) { $box->{$id}{value} = shift @results; }

Replies are listed 'Best First'.
Re: Re: Merging an array into an AoH
by neniro (Priest) on May 21, 2004 at 20:53 UTC
    I prefer an AoH, cause I can use them directly within HTML::Template. The solutions above ar quite cool, especially BrowserUKs.
    Thanks a lot!