in reply to while/push to map, data structure confusion
This example code does the transformation you want.
Update: which, of course, looks very similar to dragonchild's solution, because it's doing basically the same thing.#!perl use Data::Dumper; $rows = [[qw(1234 foo fooval)],[qw(1235 bar barval)],[qw(1234 quux quu +xval)]]; my %hash; for (@$rows) { push @{$hash{$_->[0]}} , { option => $_->[1] , option_data => $_->[2] } ; } print Dumper(\%hash);
|
|---|