in reply to help :)

It is not clear (to me) what you are trying to do, but you may be able to use something like Algorithm::ClusterPoints from CPAN.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams