my %table = ( 561231 => 'whatever', 700000 => 'whatevr2', ... ); my @thresh = sort { $a <=> $b } keys %table; $_ = pop(@thresh) while $thresh[0] < $numbers; my $contig = $table{$_};