my @missing; { my $i = 0; for ( $list[ 0 ] .. $list[ -1 ] ) { ++$i, next if $_ == $list[ $i ]; push @missing, $_; } }