- or download this
my @A = (1,2,3,4,5,4,3,2,1,2);
my @B = (2,4,6,8,10,8,6,4,2);
...
for (sort keys %Pairs){
print "$_:\n", map(" $_\n", map(join('-', @$_), @{ $Pairs{$_} })),
+"\n";
}
- or download this
push @{ $First{ $A[$_] } }, $_ for (0..$#A);
push @{ $Second{ $B[$_] } }, $_ for (0..$#B);
- or download this
for my $Common (grep {exists $Second{$_}} keys %First){
- or download this
for my $Idx (@{ $First{$Common} }){
push @{ $Pairs{$Common} }, map([$Idx, $_], @{ $Second{$Common} });
}
- or download this
$Pairs{Each Common Value} = [ [A1, B1], [A1, B2], [A2, B1], [A2, B2]
+ ]
- or download this
$Pairs{4} = [[3,1], [3,7], [5,1], [5,7]]
- or download this
2:
1-0
...
3-7
5-1
5-7