use strict; use warnings; use feature 'say'; my @x = ( -2, 3, 2, 10, 15, 8 ); my %y = map { $_ => 1 } @x; @x = sort {$a <=> $b} @x; say "missing: $_" for grep { ! exists $y{$_} } $x[0] .. $x[-1];