for my $list (@array) { my %hash = map { s/\s//g; $_->{ID2} => $_->{ID3} } @{ $list }; }