in reply to Find a number in a list closest to a target

You say you only want the one which is closest. So instead of using spacec saving data you don't need, and undergoing the expense of a sort, why not keep track of the closest as you go along. It's much the same as determining the minimum of a list.

$delta = time(); // has to be less than now - 1970 $minval = $min; for ( @returns ) { my $val = abs( $ctime - $_ ); if ( $val < $delta ) { $delta = $val; $minval = $_; } } print "MULTIPLE MATCH best match = $minval";
update: I see I'll have to learn to type faster!

--
TTTATCGGTCGTTATATAGATGTTTGCA