Find the closet points

Maybe you should use the search function before posting, since someone else has already asked your homework problem: https://www.sitepoint.com/community/t/find-the-closest-m-points-from-a-given-point-p

Also you should probably figure out the difference between python and perl.