in reply to Re^2: How would you code this?
in thread How would you code this?

Yeah, I realized that, but did not know whether it was important. But that's why I also said that you could remove duplicate X values if needed:
You might also change the relevant code line to:
next if $x <= $previous_x;
if you want to remove duplicate X values.