my $VAR1 = { 'A' => [0,1,2], # centroid is 1, with other elem 0 and 2 (1 +/- 1) 'B' => [1,2,3], 'C' => [2,3,4], 'D' => [3,4,5], 'E' => [4,5,6], 'F' => [5,6], # centroid is 6 but only with one elem 5 (i.e. 6-1) 'G' => [8], # next centroid is 8 but no members 'I' => [10], # same for centroid 10 }; # As the @nlist array grow larger the final hash will also grow larger.