@response = [ { 'name' => 'foo', 'id' => 'bar', 'self' => 'baz' }, { 'name' => 'foo2', 'id' => 'bar2', 'self' => 'baz2' }, ] #### my $responseref = \@response; my $filtered_response = filter ($responseref, 'name', 'id'); #### @response = [ { 'name' => 'foo', 'id' => 'bar', }, { 'name' => 'foo2', 'id' => 'bar2', }, ]