for my $array1_rec (@array1) { my $array2_rec = $array2{ $array1_rec->[0] } or next; ... Change @$array1_rec based on values from @$array2_rec ... }