in reply to Re^3: Filter array of hashes for specific keys
in thread Filter array of hashes for specific keys
%filtered_response is declared only once in the function call, so every reference to it will be identical. { %filtered_response } would work, but it would be better to move the declaration of %filtered_response inside the for loop.
Or, with a recent enough version of perl, you can use a pairwise slice:
push @filtered_responsearr, { %response{ @fields } };.
With a postfix dereference: push @filtered_responsearr, { $res->%{ @fields } }
Edit: I added the missing { } in the last line, to have a hash reference and not pairs of values.
|
|---|