in reply to iterations in a hash
G'day madM,
Welcome to the monastery.
As others have pointed out, this is a poorly worded question: you tell from all the guesswork and requests for more information. Better questions get better answers: "How do I post a question effectively?" explains how to achieve this.
Here's my take on a solution:
$ perl -Mstrict -Mwarnings -E ' my %hash = (A => 4, B => 5, C => 10, D => 2, E => 9); local $" = "\t"; for my $key (sort keys %hash) { say "@{[map { qq{$key * $_ = } . $hash{$key} * $hash{$_} } sort grep { $_ ne $key } keys %hash]}" } ' A * B = 20 A * C = 40 A * D = 8 A * E = 36 B * A = 20 B * C = 50 B * D = 10 B * E = 45 C * A = 40 C * B = 50 C * D = 20 C * E = 90 D * A = 8 D * B = 10 D * C = 20 D * E = 18 E * A = 36 E * B = 45 E * C = 90 E * D = 18
-- Ken
|
|---|