I have a feeling we're making your problem bigger than it really is. While I'm of the opinion that this really should be fixed with a better index on the database side, you've asked for a perl solution so I'll provide as basic one as I can.

Grab the information for the lines and concat them into a string separated by a comma. Simply add it on to a an array.
$string = "$a,$b"; push(@array, $string);
Then once you've loaded all lines into the array, you can grab the point data and loop through them. You can store the points into an array and since it's just a number, just store it as is (no need to turn it into a string). For each point you'll want to do something like this
foreach my $value (@array) { my($a,$b) = split(/,/, $value); if($x >= $a && $x <= $b) { print "This point is on the line"; } }


Please let us know if you need assistance grabbing the data from the database.

In reply to Re: fast way of working with numerical positions by fidesachates
in thread fast way of working with numerical positions by Anonymous Monk

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.