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

Aren't the printf placeholders for the 3 columns of data? I'm not sure how to fix the formula. I don't know how to iterate very well, at all. Any suggestions?

Replies are listed 'Best First'.
Re^3: Subroutine not correct (I think)
by hippo (Archbishop) on Jun 17, 2015 at 14:28 UTC

    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.