#!/usr/bin/perl
use warnings;
use strict;
my @values = qw( 11673326 11673329 11673325 11673330 11673321 11673335 );
my @sorted = sort { $a <=> $b } @values;
sub next_higher {
my ($from) = @_;
for (@sorted) {
return $_ if $_ > $from;
}
return
}
use Test::More;
is next_higher(11673326), 11673329;
is next_higher(11673335), undef;
is next_higher(11673321), 11673325;
####
#!/usr/bin/perl
use warnings;
use strict;
my $data_start = tell *DATA;
sub next_higher {
my ($from) = @_;
seek *DATA, $data_start, 0;
my $so_far;
while () {
chomp;
$so_far = $_ if $_ > $from && (! defined $so_far || $_ < $so_far);
}
return $so_far
}
use Test::More;
is next_higher(11673326), 11673329;
is next_higher(11673335), undef;
is next_higher(11673321), 11673325;
__DATA__
11673326
11673329
11673325
11673330
11673321
11673335
####
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,