# outer loop goes through all points for my $i ( 0 .. $#{$points}) { # inner loop only through those not visited yet for my $j ( ( $i + 1 ) .. $#{$points}) { # Compute the edge my $edge = sqrt( ( $points->[$i][0] - $points->[$j][0] )**2 + ( $points->[$i][1] - $points->[$j][1] )**2 ); # Push the whole thing on a stack push (@edges, [ $edge, $points->[$i][0], $points->[$i][1], $points->[$j][0], $points->[$j][1] ] ); } } }