After reading your comments through this thread that provide more details, I think I understand your problem.

You're struggling with a particular perl problem, but I think it would be most helpful to take a step back and look at the problem as a whole.

This sounds very Buddhist Monk-like, but what you want is 'A Golden Path'. A single path that covers the entire range, but uses the fewest overlapping pieces to get there.

There are several well-understood algorithms for doing that. You might try the Graph module, which provides access to several different ways of analyzing this problem (See Graph::Base). Understanding this involves some pretty heavy mathematics, but you essentially create a line (1D, not 2D) along which you place your points as vector pairs (the start point and the end point) Then apply one of the available algorithms to find the shortest connecting path. The same sort of algorithms are used in many other applications. (such as networking to find the fastest route connecting two nodes.)

Do a search on 'golden path algorithm' or some of the algorithms directly, such as 'dijkstra shortest path perl'. (That last one even has a few perl implementations, but the first one says 'use Graph instead'.)

Developing your own algorithm is certainly possible, but this is a much more complex problem than it first appears to be. Might as well use a well thought out and tested algorithm - you just have to understand that the same method of finding the shortest distance between two network nodes also applies to finding the fewest non-overlapping clones on a tiling path.

Sorry my reply is less perl and more theory, but it may be a better solution to your problem.

Update:I just found Bio::Coordinate::Graph too.

In reply to Re: Comparing 2-D co-ordinates by jmanning2k
in thread Comparing 2-D co-ordinates by aging acolyte

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.