use strict; use warnings; #print Dumper \%hash2; my %spair = (); my $prod; foreach my $si (sort { $a <=> $b } keys %hash2) { INNER: foreach my $sn (sort { $a <=> $b } keys %hash2) { if ($si == $sn) { $prod = $hash2{$si}; $spair{$si."-".$sn} = $prod; #: $hash2{$si}\n"; } else { $prod = $hash2{$si}*$hash2{$sn}; $spair{$si."-".$sn} = $prod; #: $hash2{$si}\n"; last INNER; } } } print Dumper \%spair;
In reply to Re: Self-Looping over hash - how to remove duplicate
by gaal
in thread Self-Looping over hash - how to remove duplicate
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |