in reply to A better way of lookup?

So in both perl and javascript you can use the same algorithm if you'd like.

Start with an arrary with all of your breakpoint values. I'll abridge here.

var breakpoints = [ 25000 , 50000 , 150000 ]; my @breakpoints = ( 25000 , 50000 , 150000 );

Then push the new value in. For our example I'll push in 50123.

breakpoints.push(50123); push(@breakpoints, 50123);

Sort them. Do an index-of on your value - 1.

breakpoints.sort(); var return_value = breakpoints[breakpoints.indexOf(50123) - 1]; @breakpoints = sort @breakpoints; # Use your favourite perl method for indexOf like above
In javascript this is actually cleaner than perl. The sort in javascript doesn't have to do a copy at the end and it has the 'indexOf' operator built in. </code>
--
“For the Present is the point at which time touches eternity.” - CS Lewis