in reply to Re^2: Subroutine not correct (I think)
in thread Subroutine not correct (I think)

There are five items of data in the list passed to sprintf, not three. They are:

  1. $data[$i][0]
  2. $data[$j][0]
  3. $data[$i][2]
  4. $data[$j][2]
  5. distance(\@coords_i, \@coords_j)

Therefore, your format string in the sprintf call should have enough placeholders (five!) to match this list and not merely the three currently present.