my $aref = $matches{ $fasta_id }{ $sitekey }; my( $lo, $hi ) = ( 0, scalar @{ $aref } ); ++$lo while $aref->[ $lo + 1 ] < $lowerlimit; --$hi while $aref->[ $hi - 1 ] > $upperlimit; @{ $sets{ $fasta_id }[ $setscounter ]{ $sitekey } } = @{ $aref }[ lo .. $hi ];