c:\@Work\Perl>perl -wMstrict -le "use 5.010; ;; use Test::More 'no_plan'; use Test::NoWarnings; ;; my @values = qw( 11673326 11673329 11673325 11673330 11673321 11673335 ); ;; my $sorted_str = join ' ', sort { $a <=> $b } @values; ;; sub next_higher { local our ($from) = @_; ;; return $1 if $sorted_str =~ m{ \b (\d+) \b (?(?{ $from >= $^N }) (*FAIL)) }xms; ;; return; } ;; is next_higher(11673326), 11673329; is next_higher(11673335), undef; is next_higher(11673321), 11673325; done_testing; " ok 1 ok 2 ok 3 1..3 ok 4 - no warnings 1..4