for (my $x = 0; $x <= $#tmp_numClients; $x++) { print "$AP_numClients[$x][0] \t $AP_numClients[$x][1]\n"; } __________ OUTPUT ____________ 19.25.55.11.144.0 5 19.25.55.14.16.0 12 19.25.59.200.208.0 8 19.25.59.204.160.0 7 19.25.60.5.176.0 4 19.25.60.15.48.0 0 19.25.60.17.240.0 3 19.25.60.18.96.0 5 19.25.115.138.224.0 30 19.25.115.141.32.0 4 26.109.108.64.144.0 1 38.153.162.89.0.0 1 38.153.162.89.0.1 0 38.153.162.89.96.0 0 38.153.162.89.96.1 0 38.153.162.95.64.0 0 38.153.162.95.64.1 0 58.152.64.24.192.0 1 58.152.64.24.192.1 0 58.152.64.46.48.0 3 58.152.64.46.48.1 0 58.152.94.71.0.0 1 58.152.94.71.0.1 0 #### my @newArray; for (my $x = 0; $x <= $# AP_numClients; $x++)
{ $AP_numClients[$x][0] =~ s/\.[0-1]$//; #--> remove the last digit and "." if it ends in 0 or 1 # If current element matches the next element, then add their values together... if ($AP_numClients[$x][0] =~ /$AP_numClients[$x+1][0]/) { $newArray[$x][0] = $AP_numClients[$x][0]; $newArray[$x][1] = $AP_numClients[$x][1] + $AP_numClients[$x+1][1]; $x++; } else { $newArray[$x][0] = $AP_numClients[$x][0]; $newArray[$x][1] = $AP_numClients[$x][1]; } }