in reply to Data into Array of Hashes
This should do what you want, while eliminating the need to manually map out the new hash reference. Just add or remove any keys from the @wanted array.
my @wanted = qw(code name date account street); my @array; foreach my $data (@{ $sqldata }) { push @array, { map {$_ => $data->{$_}} @wanted }; } print Dumper \@array;
|
|---|