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]; } }