my $i = 1; while ($i < @points) { if ($points[$i-1][0] > $points[$i][0]) { splice @points,$i-1,2; --$i or $i = 0; } else { $i++; } }