foreach $key (keys(%sum)) { my @excludeList = split("<->", $key); my @ipportlist = split(":",$excludeList[0]); my $firstvalue = trim($ipportlist[0]); # ip address of first my $secondvalue = $ipportlist[1]; # Port of first @ipportlist = split(":",$excludeList[1]); my $thirdvalue = trim($ipportlist[0]); # ip address of first my $forthvalue = $ipportlist[1]; # Port of firstk foreach $keyx (keys(%sum)) { @excludeList = split("<->", $keyx); @ipportlist = split(":",$excludeList[0]); my $five = trim($ipportlist[0]); # ip address of first my $six = $ipportlist[1]; # Port of first @ipportlist = split(":",$excludeList[1]); my $seven = trim($ipportlist[0]); # ip address of first my $eight = $ipportlist[1]; # Port of first { if ((($firstvalue eq $seven) && ($secondvalue == $eight)) && (($forthvalue == $six) && ($thirdvalue eq $five))) { $othcnt = $othcnt + 1; my $suma; $suma = $sum{$key} + $sum{$keyx}; print "$key \t $sum{$key} \t $sum{$keyx} \t $suma \n"; } } } }