my $current = 11673326 my ($next,@status); @status = ; $next = $current; foreach my $row (@status) { chomp($row); if(looks_like_number($row) && $current < $row && ($next == $current || $next > $row)) { $next = $row; } } __DATA__ 11673326 11673329 11673325 11673330 11673321 11673335