in reply to fast way of working with numerical positions

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.