for my $Idx (@{ $First{$Common} }){ push @{ $Pairs{$Common} }, map([$Idx, $_], @{ $Second{$Common} }); }